Giter Club home page Giter Club logo

Comments (3)

jdwilkin4 avatar jdwilkin4 commented on June 1, 2024 1

@AndrewYturaldi

The test you mentioned here only checks that the a regex variable was created and that some sort of regex is being used

assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\//);

So basically it is testing this

const regex = /some-random-stuff-goes-here/

Currently this test is checking for the correct result

Please enter a properly functioning regex.

```js

assert.strictEqual(highPrecedence("5*3"), true);

```

but it right now allows for multiple incorrect answers

does this issue require the addition of more tests?

My proposal is to rewrite the lesson to allow for more correct answers and ensure that incorrect answers don't pass.
Right now, you have to create a regex variable and you have to return regex.test(/correct-regex-goes-here/)
But there are dozens of correct answers and this should be rewritten to allow for that.

So you can see my note here for my proposed changes
#54793 (comment)

just one test that ensures the regex conforms to what was asked for (includes the two numbers, * symbol, / symbol, and 3 capture groups)?

The thing we want to be carefully about is not using regex tests to check for this.
Because that is what is happening for the other lessons and it is difficult to maintain and only allows for a specific answer.

So that is why this is marked as open for discussion 👍

from freecodecamp.

jdwilkin4 avatar jdwilkin4 commented on June 1, 2024

It looks like the last test to could be updated to include a few more assertions like this

Your `highPrecedence` function should correctly check if the string matches the pattern of a number followed by a `*` or `/` operator followed by another number.

```js

assert.isTrue(highPrecedence("5*3"));
assert.isFalse(highPrecedence("5"));
assert.isTrue(highPrecedence("10/2"));
assert.isFalse(highPrecedence("*"));
```

But also, looking at this challenge again, I think it could be simplified. At this point, we should only be testing for the final result and allow campers to solve it however they want to.

Here is my proposed update

updated description

# --description--

In your `highPrecedence` function, you should use a regex to check if the provided string matches the pattern of a number followed by a `*` or `/` operator followed by another number. 

Your function should return a boolean value. Remember that you can use the `test()` method for this.

Each number, and the operator, should be in separate capture groups.

updated tests

Your `highPrecedence` function should return a boolean value.

```js
assert.isBoolean(highPrecedence("12*2"));
```

Your `highPrecedence` function should correctly check if the string matches the pattern of a number followed by a `*` or `/` operator followed by another number.

```js

assert.isTrue(highPrecedence("5*3"));
assert.isFalse(highPrecedence("5"));
assert.isTrue(highPrecedence("10/2"));
assert.isFalse(highPrecedence("*"));
```

I'll open this up for discussion so the other members can chime in with thoughts.

from freecodecamp.

AndrewYturaldi avatar AndrewYturaldi commented on June 1, 2024

I see this as the only test for the regular expression itself:

Your regex variable should be a regular expression.

assert.match(code, /const\s+highPrecedence\s*=\s*(\(\s*str\s*\)|str)\s*=>\s*{\s*const\s+regex\s*=\s*\//);

does this issue require the addition of more tests? and if so, should there be seperate tests for each regex that produces an unexpected behavior like /5/ and /\d/ or just one test that ensures the regex conforms to what was asked for (includes the two numbers, * symbol, / symbol, and 3 capture groups)?

from freecodecamp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.