Oliver Eyton-Williams ee1e8abd87
feat(curriculum): restore seed + solution to Chinese (#40683)
* 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>
2021-01-12 19:31:00 -07:00

1.6 KiB
Raw Blame History

id, title, challengeType, videoUrl, forumTopicId, dashedName
id title challengeType videoUrl forumTopicId dashedName
56533eb9ac21ba0edf2244aa 理解未初始化的变量 1 https://scrimba.com/c/cBa2JAL 18335 understanding-uninitialized-variables

--description--

当 JavaScript 中的变量被声明的时候,程序内部会给它一个初始值undefined。当你对一个值为undefined的变量进行运算操作的时候,算出来的结果将会是NaNNaN的意思是"Not a Number"。当你用一个值是undefined的变量来做字符串拼接操作的时候,它会输出字符串"undefined"

--instructions--

定义 3 个变量abc,并且分别给他们赋值:510"I am a",这样它们值就不会是undefined了。

--hints--

a应该被定义,并且值为6

assert(typeof a === 'number' && a === 6);

b应该被定义,并且值为15

assert(typeof b === 'number' && b === 15);

c的值不能包含undefined,应该为 "I am a String!"。

assert(!/undefined/.test(c) && c === 'I am a String!');

不要修改第二条注释下的代码。

assert(
  /a = a \+ 1;/.test(code) &&
    /b = b \+ 5;/.test(code) &&
    /c = c \+ " String!";/.test(code)
);

--seed--

--after-user-code--

(function(a,b,c){ return "a = " + a + ", b = " + b + ", c = '" + c + "'"; })(a,b,c);

--seed-contents--

// Only change code below this line
var a;
var b;
var c;
// Only change code above this line

a = a + 1;
b = b + 5;
c = c + " String!";

--solutions--

var a = 5;
var b = 10;
var c = "I am a";
a = a + 1;
b = b + 5;
c = c + " String!";