Files
HenMoshe d3304276ca fix(curriculum) : Make tests stricter for challenge "Decrement a number with javascript" (#45242)
* Make tests stricter for challenge "Decrement a number with javascript" #44648

* Update decrement-a-number-with-javascript.md
2022-03-09 22:47:02 -06:00

1.2 KiB

id, title, challengeType, videoUrl, forumTopicId, dashedName
id title challengeType videoUrl forumTopicId dashedName
56533eb9ac21ba0edf2244ad Decrement a Number with JavaScript 1 https://scrimba.com/c/cM2KeS2 17558 decrement-a-number-with-javascript

--description--

You can easily decrement or decrease a variable by one with the -- operator.

i--;

is the equivalent of

i = i - 1;

Note: The entire line becomes i--;, eliminating the need for the equal sign.

--instructions--

Change the code to use the -- operator on myVar.

--hints--

myVar should equal 10.

assert(myVar === 10);

myVar = myVar - 1; should be changed.

assert(!code.match(/myVar\s*=\s*myVar\s*[-]\s*1.*?;?/));

You should not assign myVar with 10.

assert(!code.match(/myVar\s*=\s*10.*?;?/));

You should use the -- operator on myVar.

assert(/[-]{2}\s*myVar|myVar\s*[-]{2}/.test(code));

You should not change code above the specified comment.

assert(/let myVar = 11;/.test(code));

--seed--

--after-user-code--

(function(z){return 'myVar = ' + z;})(myVar);

--seed-contents--

let myVar = 11;

// Only change code below this line
myVar = myVar - 1;

--solutions--

let myVar = 11;
myVar--;