1.3 KiB
1.3 KiB
id | title | challengeType | videoUrl | forumTopicId | dashedName |
---|---|---|---|---|---|
56533eb9ac21ba0edf2244b0 | Assegnazione composta con sottrazione aumentata | 1 | https://scrimba.com/c/c2Qv7AV | 16660 | compound-assignment-with-augmented-subtraction |
--description--
Come l'operatore +=
, -=
sottrae un numero da una variabile.
myVar = myVar - 5;
sottrarrà 5
da myVar
. Questo può essere riscritto come:
myVar -= 5;
--instructions--
Converti le assegnazioni per a
, b
e c
in modo da utilizzare l'operatore -=
.
--hints--
a
dovrebbe essere uguale a 5
.
assert(a === 5);
b
dovrebbe essere uguale a -6
.
assert(b === -6);
c
dovrebbe essere uguale a 2
.
assert(c === 2);
Dovresti usare l'operatore -=
per ogni variabile.
assert(code.match(/-=/g).length === 3);
Non dovresti modificare il codice sopra il commento specificato.
assert(
/let a = 11;/.test(code) && /let b = 9;/.test(code) && /let c = 3;/.test(code)
);
--seed--
--after-user-code--
(function(a,b,c){ return "a = " + a + ", b = " + b + ", c = " + c; })(a,b,c);
--seed-contents--
let a = 11;
let b = 9;
let c = 3;
// Only change code below this line
a = a - 6;
b = b - 15;
c = c - 1;
--solutions--
let a = 11;
let b = 9;
let c = 3;
a -= 6;
b -= 15;
c -= 1;