* 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.4 KiB
1.4 KiB
id, title, challengeType, videoUrl, forumTopicId, dashedName
id | title | challengeType | videoUrl | forumTopicId | dashedName |
---|---|---|---|---|---|
56533eb9ac21ba0edf2244a8 | 使用赋值运算符存储值 | 1 | https://scrimba.com/c/cEanysE | 18310 | storing-values-with-the-assignment-operator |
--description--
在 JavaScript 中,你可以使用赋值运算符将值存储在变量中。
myVariable = 5;
这条语句把Number
类型的值5
赋给变量myVariable
。
赋值过程是从右到左进行的。在将值分配给运算符左侧的变量之前,将解析=
运算符右侧的所有内容。
myVar = 5;
myNum = myVar;
数值5
被赋给变量myVar
中,然后再次将变量myVar
解析为5
并将其赋给myNum
变量。
--instructions--
把数值7
赋给变量 a
。
把变量a
中的内容赋给变量b
。
--hints--
不要修改注释上方的代码。
assert(/var a;/.test(code) && /var b = 2;/.test(code));
a
的值应该是 7。
assert(typeof a === 'number' && a === 7);
b
的值应该是 7。
assert(typeof b === 'number' && b === 7);
你需要用=
把a
的值赋给b
。
assert(/b\s*=\s*a\s*;/g.test(code));
--seed--
--before-user-code--
if (typeof a != 'undefined') {
a = undefined;
}
--after-user-code--
(function(a){return "a = " + a;})(a);
--seed-contents--
// Setup
var a;
// Only change code below this line
--solutions--
var a;
a = 7;