1.2 KiB
1.2 KiB
id, title, challengeType, videoUrl, forumTopicId, dashedName
id | title | challengeType | videoUrl | forumTopicId | dashedName |
---|---|---|---|---|---|
56533eb9ac21ba0edf2244ad | 数字递减 | 1 | https://scrimba.com/c/cM2KeS2 | 17558 | decrement-a-number-with-javascript |
--description--
使用自减符号 --
,你可以很方便地对一个变量执行自减或者 -1 运算。
i--;
等效于:
i = i - 1;
注意:i--;
这种写法省去了书写等号的必要。
--instructions--
修改代码,使用 --
符号对 myVar
执行自减操作。
--hints--
myVar
应该等于10
。
assert(myVar === 10);
应该修改 myVar = myVar - 1;
。
assert(!code.match(/myVar\s*=\s*myVar\s*[-]\s*1.*?;?/));
你不应将 10
分配给 myVar
。
assert(!code.match(/myVar\s*=\s*10.*?;?/));
应该对 myVar
使用 --
运算符。
assert(/[-]{2}\s*myVar|myVar\s*[-]{2}/.test(code));
你不应该修改注释上面的代码。
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--;