* feat(tools): add seed/solution restore script * chore(curriculum): remove empty sections' markers * chore(curriculum): add seed + solution to Chinese * chore: remove old formatter * fix: update getChallenges parse translated challenges separately, without reference to the source * chore(curriculum): add dashedName to English * chore(curriculum): add dashedName to Chinese * refactor: remove unused challenge property 'name' * fix: relax dashedName requirement * fix: stray tag Remove stray `pre` tag from challenge file. Signed-off-by: nhcarrigan <nhcarrigan@gmail.com> Co-authored-by: nhcarrigan <nhcarrigan@gmail.com>
1.6 KiB
1.6 KiB
id, title, challengeType, videoUrl, forumTopicId, dashedName
id | title | challengeType | videoUrl | forumTopicId | dashedName |
---|---|---|---|---|---|
56533eb9ac21ba0edf2244af | Compound Assignment With Augmented Addition | 1 | https://scrimba.com/c/cDR6LCb | 16661 | compound-assignment-with-augmented-addition |
--description--
In programming, it is common to use assignments to modify the contents of a variable. Remember that everything to the right of the equals sign is evaluated first, so we can say:
myVar = myVar + 5;
to add 5
to myVar
. Since this is such a common pattern, there are operators which do both a mathematical operation and assignment in one step.
One such operator is the +=
operator.
var myVar = 1;
myVar += 5;
console.log(myVar); // Returns 6
--instructions--
Convert the assignments for a
, b
, and c
to use the +=
operator.
--hints--
a
should equal 15
.
assert(a === 15);
b
should equal 26
.
assert(b === 26);
c
should equal 19
.
assert(c === 19);
You should use the +=
operator for each variable.
assert(code.match(/\+=/g).length === 3);
You should not modify the code above the specified comment.
assert(
/var a = 3;/.test(code) &&
/var b = 17;/.test(code) &&
/var c = 12;/.test(code)
);
--seed--
--after-user-code--
(function(a,b,c){ return "a = " + a + ", b = " + b + ", c = " + c; })(a,b,c);
--seed-contents--
var a = 3;
var b = 17;
var c = 12;
// Only change code below this line
a = a + 12;
b = 9 + b;
c = c + 7;
--solutions--
var a = 3;
var b = 17;
var c = 12;
a += 12;
b += 9;
c += 7;