Comments (3)
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.
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.
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)
- Rename currentWeapon variable to currentWeaponIndex HOT 2
- Replace `hidden-xs` class with an `isMobile` check HOT 2
- JavaScript Algorithms and Data Structures (Beta) - Step 13 HOT 10
- [Certification Projects] Update the instruction to mention that the users need to manually save their code HOT 4
- Update remaining S3 links to new CDN links
- Add a new step 1 to better explain what the pyramid generator is about HOT 9
- Icon in the Help button should be hidden from screen readers
- Teach unreachable code and scope in separate lessons for pyramid project HOT 7
- remove __pyodide now that all the tests use runPython.
- Remove __locals now that all tests access variables directly
- Step 1 of RPS project allows for incorrect answers
- JS Beta Project: build a pyramid generator steps 82 and 83 do not have proper indenting for the if statement
- Add step to teach else if statements in pyramid project HOT 1
- typo in step 4 of js beta review project for building a gradebook app HOT 7
- Typo in Step 43 of Building a Cipher HOT 4
- js beta rpg step 23 - code check doesn't accept shorthand margin specification HOT 1
- Wrap keywords inside backticks in Step 51 of Building a Cipher HOT 1
- 1111
- Contributing guidelines landing page redirects to incorrect link HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from freecodecamp.