Make tests stricter for challenge "Decrement a number with javascript"
See original GitHub issueYou can pass the test by assigning 10 to the variable after decrementing it past that value.
It also doesn’t seem like the…
myVar = myVar - 1;
should be changed.
…test is not working.
Incorrect code that is passing:
let myVar = 11;
// Only change code below this line
myVar = myVar - 1;
myVar--;
myVar = 10;
Forum: https://forum.freecodecamp.org/t/decrement-a-number-with-javascript-solution/490852
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
Decrement a Number with JavaScript - Free Code Camp
In today's basic JavaScript tutorial, we utilize the decrement syntax. This is a fundamental lesson in JavaScript so it's important that you ...
Read more >Decrement a Number with Javascript, freeCodeCamp Basic ...
In this challenge we find out how to decrement a variable by one. This can be done with the double minus sign "--"....
Read more >Decrement (--) - JavaScript - MDN Web Docs - Mozilla
The decrement operator can only be applied on operands that are references (variables and object properties; i.e. valid assignment targets).
Read more >Decrement a Number with JavaScript Help!
Now for the challenge you will have to decrement myVar . One way would be: myVar = myVar -1 , but they want...
Read more >3 Amazing Types of Patterns in JavaScript - eduCBA
Design patterns are essential to solving this challenge – providing an ... Patterns in JavaScript (Number Patterns, Star Patterns, Character Patterns).
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@ShaunSHamilton I don’t think your example is equivalent at all. The end value is supposed to be the result of decrementing, not just assigning a final value.
Clearly, they do not if they can not decrement the starting value to the final value that is asked for. I see no reason why anyone that understands what the challenge is asking for would do that assignment.
We are not just blindly looking for the
--
operator to be used. We are looking for the value11
to be decremented to10
using the operator.An example would be a lesson where you ask someone to use a word in a sentence and they use the word incorrectly. They may have used the word but if it is used incorrectly they do not understand the word. Using it in a sentence means correctly using it, not just blindly shoving it into a sentence.
I would think a test with a regex that looks for an assignment to be good enough here.
I see, thank you for the clarification!