fix(i18n): chinese test suite (#38220)
* fix: Chinese test suite Add localeTiltes, descriptions, and adjust test text and testStrings to get the automated test suite working. * fix: ran script, updated testStrings and solutions
This commit is contained in:
committed by
Mrugesh Mohapatra
parent
6a7a7e6d7d
commit
b3213fc892
@ -18,9 +18,9 @@ localeTitle: 使用索引访问数组数据
|
||||
```yml
|
||||
tests:
|
||||
- text: 变量<code>myData</code>应该等于<code>myArray</code>的第一个值。
|
||||
testString: 'assert((function(){if(typeof myArray !== "undefined" && typeof myData !== "undefined" && myArray[0] === myData){return true;}else{return false;}})(), "The variable <code>myData</code> should equal the first value of <code>myArray</code>.");'
|
||||
testString: assert((function(){if(typeof myArray !== 'undefined' && typeof myData !== 'undefined' && myArray[0] === myData){return true;}else{return false;}})());
|
||||
- text: 应使用括号表示法访问变量<code>myArray</code>的数据。
|
||||
testString: 'assert((function(){if(code.match(/\s*=\s*myArray\[0\]/g)){return true;}else{return false;}})(), "The data in variable <code>myArray</code> should be accessed using bracket notation.");'
|
||||
testString: assert((function(){if(code.match(/\s*=\s*myArray\[0\]/g)){return true;}else{return false;}})());
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,9 +18,9 @@ localeTitle: 访问带索引的多维数组
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>myData</code>应该等于<code>8</code> 。
|
||||
testString: 'assert(myData === 8, "<code>myData</code> should be equal to <code>8</code>.");'
|
||||
testString: assert(myData === 8);
|
||||
- text: 您应该使用括号表示法从<code>myArray</code>读取正确的值。
|
||||
testString: 'assert(/myArray\[2\]\[1\]/g.test(code) && !/myData\s*=\s*(?:.*[-+*/%]|\d)/g.test(code), "You should be using bracket notation to read the correct value from <code>myArray</code>.");'
|
||||
testString: assert(/myData=myArray\[2\]\[1\]/.test(code.replace(/\s/g, '')));
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,9 +18,9 @@ localeTitle: 访问嵌套数组
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>secondTree</code>应该等于“松树”
|
||||
testString: 'assert(secondTree === "pine", "<code>secondTree</code> should equal "pine"");'
|
||||
testString: assert(secondTree === "pine");
|
||||
- text: 使用点和括号表示法访问<code>myPlants</code>
|
||||
testString: 'assert(/=\s*myPlants\[1\].list\[1\]/.test(code), "Use dot and bracket notation to access <code>myPlants</code>");'
|
||||
testString: assert(/=\s*myPlants\[1\].list\[1\]/.test(code));
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,9 +18,9 @@ localeTitle: 访问嵌套对象
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>gloveBoxContents</code>应该等于“地图”
|
||||
testString: 'assert(gloveBoxContents === "maps", "<code>gloveBoxContents</code> should equal "maps"");'
|
||||
testString: assert(gloveBoxContents === "maps");
|
||||
- text: 使用点和括号表示法访问<code>myStorage</code>
|
||||
testString: 'assert(/=\s*myStorage\.car\.inside\[\s*("|")glove box\1\s*\]/g.test(code), "Use dot and bracket notation to access <code>myStorage</code>");'
|
||||
testString: assert(/=\s*myStorage\.car\.inside\[\s*("|')glove box\1\s*\]/g.test(code));
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,15 +18,15 @@ localeTitle: 使用括号表示法访问对象属性
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>entreeValue</code>应该是一个字符串
|
||||
testString: 'assert(typeof entreeValue === "string" , "<code>entreeValue</code> should be a string");'
|
||||
testString: assert(typeof entreeValue === 'string' );
|
||||
- text: <code>entreeValue</code>的值应该是<code>"hamburger"</code>
|
||||
testString: 'assert(entreeValue === "hamburger" , "The value of <code>entreeValue</code> should be <code>"hamburger"</code>");'
|
||||
testString: assert(entreeValue === 'hamburger' );
|
||||
- text: <code>drinkValue</code>应该是一个字符串
|
||||
testString: 'assert(typeof drinkValue === "string" , "<code>drinkValue</code> should be a string");'
|
||||
testString: assert(typeof drinkValue === 'string' );
|
||||
- text: <code>drinkValue</code>的值应该是<code>"water"</code>
|
||||
testString: 'assert(drinkValue === "water" , "The value of <code>drinkValue</code> should be <code>"water"</code>");'
|
||||
testString: assert(drinkValue === 'water' );
|
||||
- text: 您应该使用括号表示法两次
|
||||
testString: 'assert(code.match(/testObj\s*?\[("|")[^""]+\1\]/g).length > 1, "You should use bracket notation twice");'
|
||||
testString: assert(code.match(/testObj\s*?\[('|")[^'"]+\1\]/g).length > 1);
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,15 +18,15 @@ localeTitle: 使用点表示法访问对象属性
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>hatValue</code>应该是一个字符串
|
||||
testString: 'assert(typeof hatValue === "string" , "<code>hatValue</code> should be a string");'
|
||||
testString: assert(typeof hatValue === 'string' );
|
||||
- text: <code>hatValue</code>的值应该是<code>"ballcap"</code>
|
||||
testString: 'assert(hatValue === "ballcap" , "The value of <code>hatValue</code> should be <code>"ballcap"</code>");'
|
||||
testString: assert(hatValue === 'ballcap' );
|
||||
- text: <code>shirtValue</code>应该是一个字符串
|
||||
testString: 'assert(typeof shirtValue === "string" , "<code>shirtValue</code> should be a string");'
|
||||
testString: assert(typeof shirtValue === 'string' );
|
||||
- text: <code>shirtValue</code>的值应该是<code>"jersey"</code>
|
||||
testString: 'assert(shirtValue === "jersey" , "The value of <code>shirtValue</code> should be <code>"jersey"</code>");'
|
||||
testString: assert(shirtValue === 'jersey' );
|
||||
- text: 你应该使用点符号两次
|
||||
testString: 'assert(code.match(/testObj\.\w+/g).length > 1, "You should use dot notation twice");'
|
||||
testString: assert(code.match(/testObj\.\w+/g).length > 1);
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,17 +18,17 @@ localeTitle: 使用变量访问对象属性
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>playerNumber</code>应该是一个数字
|
||||
testString: 'assert(typeof playerNumber === "number", "<code>playerNumber</code> should be a number");'
|
||||
testString: assert(typeof playerNumber === 'number');
|
||||
- text: 变量<code>player</code>应该是一个字符串
|
||||
testString: 'assert(typeof player === "string", "The variable <code>player</code> should be a string");'
|
||||
testString: assert(typeof player === 'string');
|
||||
- text: <code>player</code>的价值应该是“蒙大拿”
|
||||
testString: 'assert(player === "Montana", "The value of <code>player</code> should be "Montana"");'
|
||||
testString: assert(player === 'Montana');
|
||||
- text: 您应该使用括号表示法来访问<code>testObj</code>
|
||||
testString: 'assert(/testObj\s*?\[.*?\]/.test(code),"You should use bracket notation to access <code>testObj</code>");'
|
||||
testString: assert(/testObj\s*?\[.*?\]/.test(code));
|
||||
- text: 您不应该直接将值<code>Montana</code>分配给变量<code>player</code> 。
|
||||
testString: 'assert(!code.match(/player\s*=\s*"|\"\s*Montana\s*"|\"\s*;/gi),"You should not assign the value <code>Montana</code> to the variable <code>player</code> directly.");'
|
||||
testString: assert(!code.match(/player\s*=\s*"|\'\s*Montana\s*"|\'\s*;/gi));
|
||||
- text: 您应该在括号表示法中使用变量<code>playerNumber</code>
|
||||
testString: 'assert(/testObj\s*?\[\s*playerNumber\s*\]/.test(code),"You should be using the variable <code>playerNumber</code> in your bracket notation");'
|
||||
testString: assert(/testObj\s*?\[\s*playerNumber\s*\]/.test(code));
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,9 +18,9 @@ localeTitle: 将新属性添加到JavaScript对象
|
||||
```yml
|
||||
tests:
|
||||
- text: 将属性<code>"bark"</code>添加到<code>myDog</code> 。
|
||||
testString: 'assert(myDog.bark !== undefined, "Add the property <code>"bark"</code> to <code>myDog</code>.");'
|
||||
testString: assert(myDog.bark !== undefined);
|
||||
- text: 不要在设置部分添加<code>"bark"</code>
|
||||
testString: 'assert(!/bark[^\n]:/.test(code), "Do not add <code>"bark"</code> to the setup section");'
|
||||
testString: assert(!/bark[^\n]:/.test(code));
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,9 +18,9 @@ localeTitle: 使用JavaScript添加两个数字
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>sum</code>应该等于<code>20</code>
|
||||
testString: 'assert(sum === 20, "<code>sum</code> should equal <code>20</code>");'
|
||||
testString: assert(sum === 20);
|
||||
- text: 使用<code>+</code>运算符
|
||||
testString: 'assert(/\+/.test(code), "Use the <code>+</code> operator");'
|
||||
testString: assert(/\+/.test(code));
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,21 +18,21 @@ localeTitle: 在交换机语句中添加默认选项
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>switchOfStuff("a")</code>的值应为“apple”
|
||||
testString: 'assert(switchOfStuff("a") === "apple", "<code>switchOfStuff("a")</code> should have a value of "apple"");'
|
||||
testString: assert(switchOfStuff("a") === "apple");
|
||||
- text: <code>switchOfStuff("b")</code>的值应为“bird”
|
||||
testString: 'assert(switchOfStuff("b") === "bird", "<code>switchOfStuff("b")</code> should have a value of "bird"");'
|
||||
testString: assert(switchOfStuff("b") === "bird");
|
||||
- text: <code>switchOfStuff("c")</code>的值应为“cat”
|
||||
testString: 'assert(switchOfStuff("c") === "cat", "<code>switchOfStuff("c")</code> should have a value of "cat"");'
|
||||
testString: assert(switchOfStuff("c") === "cat");
|
||||
- text: <code>switchOfStuff("d")</code>的值应为“stuff”
|
||||
testString: 'assert(switchOfStuff("d") === "stuff", "<code>switchOfStuff("d")</code> should have a value of "stuff"");'
|
||||
testString: assert(switchOfStuff("d") === "stuff");
|
||||
- text: <code>switchOfStuff(4)</code>的值应为“stuff”
|
||||
testString: 'assert(switchOfStuff(4) === "stuff", "<code>switchOfStuff(4)</code> should have a value of "stuff"");'
|
||||
testString: assert(switchOfStuff(4) === "stuff");
|
||||
- text: 您不应该使用任何<code>if</code>或<code>else</code>语句
|
||||
testString: 'assert(!/else/g.test(code) || !/if/g.test(code), "You should not use any <code>if</code> or <code>else</code> statements");'
|
||||
testString: assert(!/else/g.test(code) || !/if/g.test(code));
|
||||
- text: 您应该使用<code>default</code>语句
|
||||
testString: 'assert(switchOfStuff("string-to-trigger-default-case") === "stuff", "You should use a <code>default</code> statement");'
|
||||
testString: assert(switchOfStuff("string-to-trigger-default-case") === "stuff");
|
||||
- text: 你应该至少有3个<code>break</code>语句
|
||||
testString: 'assert(code.match(/break/g).length > 2, "You should have at least 3 <code>break</code> statements");'
|
||||
testString: assert(code.match(/break/g).length > 2);
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,9 +18,9 @@ localeTitle: 将变量附加到字符串
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>someAdjective</code>应设置为至少3个字符长的字符串
|
||||
testString: 'assert(typeof someAdjective !== "undefined" && someAdjective.length > 2, "<code>someAdjective</code> should be set to a string at least 3 characters long");'
|
||||
testString: assert(typeof someAdjective !== 'undefined' && someAdjective.length > 2);
|
||||
- text: 使用<code>+=</code>运算符将<code>someAdjective</code>附加到<code>myStr</code>
|
||||
testString: 'assert(code.match(/myStr\s*\+=\s*someAdjective\s*/).length > 0, "Append <code>someAdjective</code> to <code>myStr</code> using the <code>+=</code> operator");'
|
||||
testString: assert(code.match(/myStr\s*\+=\s*someAdjective\s*/).length > 0);
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,9 +18,9 @@ localeTitle: 具有返回值的分配
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>processed</code>的值应为<code>2</code>
|
||||
testString: 'assert(processed === 2, "<code>processed</code> should have a value of <code>2</code>");'
|
||||
testString: assert(processed === 2);
|
||||
- text: 您应该将<code>processArg</code>分配给已<code>processed</code>
|
||||
testString: 'assert(/processed\s*=\s*processArg\(\s*7\s*\)\s*;/.test(code), "You should assign <code>processArg</code> to <code>processed</code>");'
|
||||
testString: assert(/processed\s*=\s*processArg\(\s*7\s*\)/.test(code));
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,15 +18,15 @@ localeTitle: 构建JavaScript对象
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>myDog</code>应该包含属性<code>name</code> ,它应该是一个<code>string</code> 。
|
||||
testString: 'assert((function(z){if(z.hasOwnProperty("name") && z.name !== undefined && typeof z.name === "string"){return true;}else{return false;}})(myDog), "<code>myDog</code> should contain the property <code>name</code> and it should be a <code>string</code>.");'
|
||||
testString: assert((function(z){if(z.hasOwnProperty("name") && z.name !== undefined && typeof z.name === "string"){return true;}else{return false;}})(myDog));
|
||||
- text: <code>myDog</code>应该包含属性<code>legs</code> ,它应该是一个<code>number</code> 。
|
||||
testString: 'assert((function(z){if(z.hasOwnProperty("legs") && z.legs !== undefined && typeof z.legs === "number"){return true;}else{return false;}})(myDog), "<code>myDog</code> should contain the property <code>legs</code> and it should be a <code>number</code>.");'
|
||||
testString: assert((function(z){if(z.hasOwnProperty("legs") && z.legs !== undefined && typeof z.legs === "number"){return true;}else{return false;}})(myDog));
|
||||
- text: <code>myDog</code>应该包含属性<code>tails</code> ,它应该是一个<code>number</code> 。
|
||||
testString: 'assert((function(z){if(z.hasOwnProperty("tails") && z.tails !== undefined && typeof z.tails === "number"){return true;}else{return false;}})(myDog), "<code>myDog</code> should contain the property <code>tails</code> and it should be a <code>number</code>.");'
|
||||
testString: assert((function(z){if(z.hasOwnProperty("tails") && z.tails !== undefined && typeof z.tails === "number"){return true;}else{return false;}})(myDog));
|
||||
- text: <code>myDog</code>应该包含属性<code>friends</code> ,它应该是一个<code>array</code> 。
|
||||
testString: 'assert((function(z){if(z.hasOwnProperty("friends") && z.friends !== undefined && Array.isArray(z.friends)){return true;}else{return false;}})(myDog), "<code>myDog</code> should contain the property <code>friends</code> and it should be an <code>array</code>.");'
|
||||
testString: assert((function(z){if(z.hasOwnProperty("friends") && z.friends !== undefined && Array.isArray(z.friends)){return true;}else{return false;}})(myDog));
|
||||
- text: <code>myDog</code>应该只包含所有给定的属性。
|
||||
testString: 'assert((function(z){return Object.keys(z).length === 4;})(myDog), "<code>myDog</code> should only contain all the given properties.");'
|
||||
testString: assert((function(z){return Object.keys(z).length === 4;})(myDog));
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,31 +18,31 @@ localeTitle: 链接如果其他声明
|
||||
```yml
|
||||
tests:
|
||||
- text: 你应该至少有四个<code>else</code>语句
|
||||
testString: 'assert(code.match(/else/g).length > 3, "You should have at least four <code>else</code> statements");'
|
||||
testString: assert(code.match(/else/g).length > 3);
|
||||
- text: 你应该至少有四个<code>if</code>语句
|
||||
testString: 'assert(code.match(/if/g).length > 3, "You should have at least four <code>if</code> statements");'
|
||||
testString: assert(code.match(/if/g).length > 3);
|
||||
- text: 你应该至少有一个<code>return</code>语句
|
||||
testString: 'assert(code.match(/return/g).length >= 1, "You should have at least one <code>return</code> statement");'
|
||||
testString: assert(code.match(/return/g).length >= 1);
|
||||
- text: <code>testSize(0)</code>应该返回“Tiny”
|
||||
testString: 'assert(testSize(0) === "Tiny", "<code>testSize(0)</code> should return "Tiny"");'
|
||||
testString: assert(testSize(0) === "Tiny");
|
||||
- text: <code>testSize(4)</code>应该返回“Tiny”
|
||||
testString: 'assert(testSize(4) === "Tiny", "<code>testSize(4)</code> should return "Tiny"");'
|
||||
testString: assert(testSize(4) === "Tiny");
|
||||
- text: <code>testSize(5)</code>应返回“Small”
|
||||
testString: 'assert(testSize(5) === "Small", "<code>testSize(5)</code> should return "Small"");'
|
||||
testString: assert(testSize(5) === "Small");
|
||||
- text: <code>testSize(8)</code>应该返回“Small”
|
||||
testString: 'assert(testSize(8) === "Small", "<code>testSize(8)</code> should return "Small"");'
|
||||
testString: assert(testSize(8) === "Small");
|
||||
- text: <code>testSize(10)</code>应该返回“Medium”
|
||||
testString: 'assert(testSize(10) === "Medium", "<code>testSize(10)</code> should return "Medium"");'
|
||||
testString: assert(testSize(10) === "Medium");
|
||||
- text: <code>testSize(14)</code>应返回“Medium”
|
||||
testString: 'assert(testSize(14) === "Medium", "<code>testSize(14)</code> should return "Medium"");'
|
||||
testString: assert(testSize(14) === "Medium");
|
||||
- text: <code>testSize(15)</code>应该返回“Large”
|
||||
testString: 'assert(testSize(15) === "Large", "<code>testSize(15)</code> should return "Large"");'
|
||||
testString: assert(testSize(15) === "Large");
|
||||
- text: <code>testSize(17)</code>应该返回“Large”
|
||||
testString: 'assert(testSize(17) === "Large", "<code>testSize(17)</code> should return "Large"");'
|
||||
testString: assert(testSize(17) === "Large");
|
||||
- text: <code>testSize(20)</code>应该返回“巨大”
|
||||
testString: 'assert(testSize(20) === "Huge", "<code>testSize(20)</code> should return "Huge"");'
|
||||
testString: assert(testSize(20) === "Huge");
|
||||
- text: <code>testSize(25)</code>应该返回“巨大”
|
||||
testString: 'assert(testSize(25) === "Huge", "<code>testSize(25)</code> should return "Huge"");'
|
||||
testString: assert(testSize(25) === "Huge");
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,9 +18,9 @@ localeTitle: 评论您的JavaScript代码
|
||||
```yml
|
||||
tests:
|
||||
- text: 创建一个包含至少五个字母的<code>//</code>样式注释。
|
||||
testString: 'assert(code.match(/(\/\/)...../g), "Create a <code>//</code> style comment that contains at least five letters.");'
|
||||
testString: assert(code.match(/(\/\/)...../g));
|
||||
- text: 创建包含至少五个字母的<code>/* */</code>样式注释。
|
||||
testString: 'assert(code.match(/(\/\*)([^\/]{5,})(?=\*\/)/gm), "Create a <code>/* */</code> style comment that contains at least five letters.");'
|
||||
testString: assert(code.match(/(\/\*)([^\/]{5,})(?=\*\/)/gm));
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,13 +18,13 @@ localeTitle: 与平等算子的比较
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>testEqual(10)</code>应该返回“Not Equal”
|
||||
testString: 'assert(testEqual(10) === "Not Equal", "<code>testEqual(10)</code> should return "Not Equal"");'
|
||||
testString: assert(testEqual(10) === "Not Equal");
|
||||
- text: <code>testEqual(12)</code>应返回“Equal”
|
||||
testString: 'assert(testEqual(12) === "Equal", "<code>testEqual(12)</code> should return "Equal"");'
|
||||
testString: assert(testEqual(12) === "Equal");
|
||||
- text: <code>testEqual("12")</code>应返回“Equal”
|
||||
testString: 'assert(testEqual("12") === "Equal", "<code>testEqual("12")</code> should return "Equal"");'
|
||||
testString: assert(testEqual("12") === "Equal");
|
||||
- text: 您应该使用<code>==</code>运算符
|
||||
testString: 'assert(code.match(/==/g) && !code.match(/===/g), "You should use the <code>==</code> operator");'
|
||||
testString: assert(code.match(/==/g) && !code.match(/===/g));
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,21 +18,21 @@ localeTitle: 与大于运营商的比较
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>testGreaterThan(0)</code>应返回“10或Under”
|
||||
testString: 'assert(testGreaterThan(0) === "10 or Under", "<code>testGreaterThan(0)</code> should return "10 or Under"");'
|
||||
testString: assert(testGreaterThan(0) === "10 or Under");
|
||||
- text: <code>testGreaterThan(10)</code>应返回“10或Under”
|
||||
testString: 'assert(testGreaterThan(10) === "10 or Under", "<code>testGreaterThan(10)</code> should return "10 or Under"");'
|
||||
testString: assert(testGreaterThan(10) === "10 or Under");
|
||||
- text: <code>testGreaterThan(11)</code>应该返回“Over 10”
|
||||
testString: 'assert(testGreaterThan(11) === "Over 10", "<code>testGreaterThan(11)</code> should return "Over 10"");'
|
||||
testString: assert(testGreaterThan(11) === "Over 10");
|
||||
- text: <code>testGreaterThan(99)</code>应该返回“Over 10”
|
||||
testString: 'assert(testGreaterThan(99) === "Over 10", "<code>testGreaterThan(99)</code> should return "Over 10"");'
|
||||
testString: assert(testGreaterThan(99) === "Over 10");
|
||||
- text: <code>testGreaterThan(100)</code>应该返回“Over 10”
|
||||
testString: 'assert(testGreaterThan(100) === "Over 10", "<code>testGreaterThan(100)</code> should return "Over 10"");'
|
||||
testString: assert(testGreaterThan(100) === "Over 10");
|
||||
- text: <code>testGreaterThan(101)</code>应返回“超过100”
|
||||
testString: 'assert(testGreaterThan(101) === "Over 100", "<code>testGreaterThan(101)</code> should return "Over 100"");'
|
||||
testString: assert(testGreaterThan(101) === "Over 100");
|
||||
- text: <code>testGreaterThan(150)</code>应该返回“超过100”
|
||||
testString: 'assert(testGreaterThan(150) === "Over 100", "<code>testGreaterThan(150)</code> should return "Over 100"");'
|
||||
testString: assert(testGreaterThan(150) === "Over 100");
|
||||
- text: 您应该至少使用<code>></code>运算符两次
|
||||
testString: 'assert(code.match(/val\s*>\s*("|")*\d+("|")*/g).length > 1, "You should use the <code>></code> operator at least twice");'
|
||||
testString: assert(code.match(/val\s*>\s*('|")*\d+('|")*/g).length > 1);
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,21 +18,21 @@ localeTitle: 与大于或等于运算符的比较
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>testGreaterOrEqual(0)</code>应返回“小于10”
|
||||
testString: 'assert(testGreaterOrEqual(0) === "Less than 10", "<code>testGreaterOrEqual(0)</code> should return "Less than 10"");'
|
||||
testString: assert(testGreaterOrEqual(0) === "Less than 10");
|
||||
- text: <code>testGreaterOrEqual(9)</code>应返回“小于10”
|
||||
testString: 'assert(testGreaterOrEqual(9) === "Less than 10", "<code>testGreaterOrEqual(9)</code> should return "Less than 10"");'
|
||||
testString: assert(testGreaterOrEqual(9) === "Less than 10");
|
||||
- text: <code>testGreaterOrEqual(10)</code>应返回“10或Over”
|
||||
testString: 'assert(testGreaterOrEqual(10) === "10 or Over", "<code>testGreaterOrEqual(10)</code> should return "10 or Over"");'
|
||||
testString: assert(testGreaterOrEqual(10) === "10 or Over");
|
||||
- text: <code>testGreaterOrEqual(11)</code>应返回“10或Over”
|
||||
testString: 'assert(testGreaterOrEqual(11) === "10 or Over", "<code>testGreaterOrEqual(11)</code> should return "10 or Over"");'
|
||||
testString: assert(testGreaterOrEqual(11) === "10 or Over");
|
||||
- text: <code>testGreaterOrEqual(19)</code>应返回“10或Over”
|
||||
testString: 'assert(testGreaterOrEqual(19) === "10 or Over", "<code>testGreaterOrEqual(19)</code> should return "10 or Over"");'
|
||||
testString: assert(testGreaterOrEqual(19) === "10 or Over");
|
||||
- text: <code>testGreaterOrEqual(100)</code>应该返回“20或Over”
|
||||
testString: 'assert(testGreaterOrEqual(100) === "20 or Over", "<code>testGreaterOrEqual(100)</code> should return "20 or Over"");'
|
||||
testString: assert(testGreaterOrEqual(100) === "20 or Over");
|
||||
- text: <code>testGreaterOrEqual(21)</code>应返回“20或Over”
|
||||
testString: 'assert(testGreaterOrEqual(21) === "20 or Over", "<code>testGreaterOrEqual(21)</code> should return "20 or Over"");'
|
||||
testString: assert(testGreaterOrEqual(21) === "20 or Over");
|
||||
- text: 您应该使用<code>>=</code>运算符至少两次
|
||||
testString: 'assert(code.match(/val\s*>=\s*("|")*\d+("|")*/g).length > 1, "You should use the <code>>=</code> operator at least twice");'
|
||||
testString: assert(code.match(/val\s*>=\s*('|")*\d+('|")*/g).length > 1);
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,17 +18,17 @@ localeTitle: 与不等式算子的比较
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>testNotEqual(99)</code>应返回“Equal”
|
||||
testString: 'assert(testNotEqual(99) === "Equal", "<code>testNotEqual(99)</code> should return "Equal"");'
|
||||
testString: assert(testNotEqual(99) === "Equal");
|
||||
- text: <code>testNotEqual("99")</code>应该返回“Equal”
|
||||
testString: 'assert(testNotEqual("99") === "Equal", "<code>testNotEqual("99")</code> should return "Equal"");'
|
||||
testString: assert(testNotEqual("99") === "Equal");
|
||||
- text: <code>testNotEqual(12)</code>应该返回“Not Equal”
|
||||
testString: 'assert(testNotEqual(12) === "Not Equal", "<code>testNotEqual(12)</code> should return "Not Equal"");'
|
||||
testString: assert(testNotEqual(12) === "Not Equal");
|
||||
- text: <code>testNotEqual("12")</code>应该返回“Not Equal”
|
||||
testString: 'assert(testNotEqual("12") === "Not Equal", "<code>testNotEqual("12")</code> should return "Not Equal"");'
|
||||
testString: assert(testNotEqual("12") === "Not Equal");
|
||||
- text: <code>testNotEqual("bob")</code>应返回“Not Equal”
|
||||
testString: 'assert(testNotEqual("bob") === "Not Equal", "<code>testNotEqual("bob")</code> should return "Not Equal"");'
|
||||
testString: assert(testNotEqual("bob") === "Not Equal");
|
||||
- text: 你应该使用<code>!=</code>运算符
|
||||
testString: 'assert(code.match(/(?!!==)!=/), "You should use the <code>!=</code> operator");'
|
||||
testString: assert(code.match(/(?!!==)!=/));
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,19 +18,19 @@ localeTitle: 与小于算子的比较
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>testLessThan(0)</code>应该返回“25岁以下”
|
||||
testString: 'assert(testLessThan(0) === "Under 25", "<code>testLessThan(0)</code> should return "Under 25"");'
|
||||
testString: assert(testLessThan(0) === "Under 25");
|
||||
- text: <code>testLessThan(24)</code>应该返回“25岁以下”
|
||||
testString: 'assert(testLessThan(24) === "Under 25", "<code>testLessThan(24)</code> should return "Under 25"");'
|
||||
testString: assert(testLessThan(24) === "Under 25");
|
||||
- text: <code>testLessThan(25)</code>应该返回“55岁以下”
|
||||
testString: 'assert(testLessThan(25) === "Under 55", "<code>testLessThan(25)</code> should return "Under 55"");'
|
||||
testString: assert(testLessThan(25) === "Under 55");
|
||||
- text: <code>testLessThan(54)</code>应该返回“55岁以下”
|
||||
testString: 'assert(testLessThan(54) === "Under 55", "<code>testLessThan(54)</code> should return "Under 55"");'
|
||||
testString: assert(testLessThan(54) === "Under 55");
|
||||
- text: <code>testLessThan(55)</code>应返回“55或以上”
|
||||
testString: 'assert(testLessThan(55) === "55 or Over", "<code>testLessThan(55)</code> should return "55 or Over"");'
|
||||
testString: assert(testLessThan(55) === "55 or Over");
|
||||
- text: <code>testLessThan(99)</code>应返回“55或以上”
|
||||
testString: 'assert(testLessThan(99) === "55 or Over", "<code>testLessThan(99)</code> should return "55 or Over"");'
|
||||
testString: assert(testLessThan(99) === "55 or Over");
|
||||
- text: 您应该至少使用<code><</code>运算符两次
|
||||
testString: 'assert(code.match(/val\s*<\s*("|")*\d+("|")*/g).length > 1, "You should use the <code><</code> operator at least twice");'
|
||||
testString: assert(code.match(/val\s*<\s*('|")*\d+('|")*/g).length > 1);
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,21 +18,21 @@ localeTitle: 与小于或等于运算符的比较
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>testLessOrEqual(0)</code>应该返回“小于或等于12”
|
||||
testString: 'assert(testLessOrEqual(0) === "Smaller Than or Equal to 12", "<code>testLessOrEqual(0)</code> should return "Smaller Than or Equal to 12"");'
|
||||
testString: assert(testLessOrEqual(0) === "Smaller Than or Equal to 12");
|
||||
- text: <code>testLessOrEqual(11)</code>应返回“小于或等于12”
|
||||
testString: 'assert(testLessOrEqual(11) === "Smaller Than or Equal to 12", "<code>testLessOrEqual(11)</code> should return "Smaller Than or Equal to 12"");'
|
||||
testString: assert(testLessOrEqual(11) === "Smaller Than or Equal to 12");
|
||||
- text: <code>testLessOrEqual(12)</code>应返回“小于或等于12”
|
||||
testString: 'assert(testLessOrEqual(12) === "Smaller Than or Equal to 12", "<code>testLessOrEqual(12)</code> should return "Smaller Than or Equal to 12"");'
|
||||
testString: assert(testLessOrEqual(12) === "Smaller Than or Equal to 12");
|
||||
- text: <code>testLessOrEqual(23)</code>应返回“小于或等于24”
|
||||
testString: 'assert(testLessOrEqual(23) === "Smaller Than or Equal to 24", "<code>testLessOrEqual(23)</code> should return "Smaller Than or Equal to 24"");'
|
||||
testString: assert(testLessOrEqual(23) === "Smaller Than or Equal to 24");
|
||||
- text: <code>testLessOrEqual(24)</code>应返回“小于或等于24”
|
||||
testString: 'assert(testLessOrEqual(24) === "Smaller Than or Equal to 24", "<code>testLessOrEqual(24)</code> should return "Smaller Than or Equal to 24"");'
|
||||
testString: assert(testLessOrEqual(24) === "Smaller Than or Equal to 24");
|
||||
- text: <code>testLessOrEqual(25)</code>应该返回“超过24”
|
||||
testString: 'assert(testLessOrEqual(25) === "More Than 24", "<code>testLessOrEqual(25)</code> should return "More Than 24"");'
|
||||
testString: assert(testLessOrEqual(25) === "More Than 24");
|
||||
- text: <code>testLessOrEqual(55)</code>应该返回“超过24”
|
||||
testString: 'assert(testLessOrEqual(55) === "More Than 24", "<code>testLessOrEqual(55)</code> should return "More Than 24"");'
|
||||
testString: assert(testLessOrEqual(55) === "More Than 24");
|
||||
- text: 你应该至少使用<code><=</code>运算符两次
|
||||
testString: 'assert(code.match(/val\s*<=\s*("|")*\d+("|")*/g).length > 1, "You should use the <code><=</code> operator at least twice");'
|
||||
testString: assert(code.match(/val\s*<=\s*('|")*\d+('|")*/g).length > 1);
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,13 +18,13 @@ localeTitle: 与严格平等算子的比较
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>testStrict(10)</code>应返回“Not Equal”
|
||||
testString: 'assert(testStrict(10) === "Not Equal", "<code>testStrict(10)</code> should return "Not Equal"");'
|
||||
testString: assert(testStrict(10) === "Not Equal");
|
||||
- text: <code>testStrict(7)</code>应返回“Equal”
|
||||
testString: 'assert(testStrict(7) === "Equal", "<code>testStrict(7)</code> should return "Equal"");'
|
||||
testString: assert(testStrict(7) === "Equal");
|
||||
- text: <code>testStrict("7")</code>应返回“Not Equal”
|
||||
testString: 'assert(testStrict("7") === "Not Equal", "<code>testStrict("7")</code> should return "Not Equal"");'
|
||||
testString: assert(testStrict("7") === "Not Equal");
|
||||
- text: 您应该使用<code>===</code>运算符
|
||||
testString: 'assert(code.match(/(val\s*===\s*\d+)|(\d+\s*===\s*val)/g).length > 0, "You should use the <code>===</code> operator");'
|
||||
testString: assert(code.match(/(val\s*===\s*\d+)|(\d+\s*===\s*val)/g).length > 0);
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,15 +18,15 @@ localeTitle: 与严格不等式算子的比较
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>testStrictNotEqual(17)</code>应返回“Equal”
|
||||
testString: 'assert(testStrictNotEqual(17) === "Equal", "<code>testStrictNotEqual(17)</code> should return "Equal"");'
|
||||
testString: assert(testStrictNotEqual(17) === "Equal");
|
||||
- text: <code>testStrictNotEqual("17")</code>应返回“Not Equal”
|
||||
testString: 'assert(testStrictNotEqual("17") === "Not Equal", "<code>testStrictNotEqual("17")</code> should return "Not Equal"");'
|
||||
testString: assert(testStrictNotEqual("17") === "Not Equal");
|
||||
- text: <code>testStrictNotEqual(12)</code>应该返回“Not Equal”
|
||||
testString: 'assert(testStrictNotEqual(12) === "Not Equal", "<code>testStrictNotEqual(12)</code> should return "Not Equal"");'
|
||||
testString: assert(testStrictNotEqual(12) === "Not Equal");
|
||||
- text: <code>testStrictNotEqual("bob")</code>应返回“Not Equal”
|
||||
testString: 'assert(testStrictNotEqual("bob") === "Not Equal", "<code>testStrictNotEqual("bob")</code> should return "Not Equal"");'
|
||||
testString: assert(testStrictNotEqual("bob") === "Not Equal");
|
||||
- text: 你应该使用<code>!==</code>运算符
|
||||
testString: 'assert(code.match(/(val\s*!==\s*\d+)|(\d+\s*!==\s*val)/g).length > 0, "You should use the <code>!==</code> operator");'
|
||||
testString: assert(code.match(/(val\s*!==\s*\d+)|(\d+\s*!==\s*val)/g).length > 0);
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,25 +18,25 @@ localeTitle: 与逻辑和运算符的比较
|
||||
```yml
|
||||
tests:
|
||||
- text: 你应该使用一次<code>&&</code>运算符
|
||||
testString: 'assert(code.match(/&&/g).length === 1, "You should use the <code>&&</code> operator once");'
|
||||
testString: assert(code.match(/&&/g).length === 1);
|
||||
- text: 你应该只有一个<code>if</code>语句
|
||||
testString: 'assert(code.match(/if/g).length === 1, "You should only have one <code>if</code> statement");'
|
||||
testString: assert(code.match(/if/g).length === 1);
|
||||
- text: <code>testLogicalAnd(0)</code>应返回“否”
|
||||
testString: 'assert(testLogicalAnd(0) === "No", "<code>testLogicalAnd(0)</code> should return "No"");'
|
||||
testString: assert(testLogicalAnd(0) === "No");
|
||||
- text: <code>testLogicalAnd(24)</code>应返回“否”
|
||||
testString: 'assert(testLogicalAnd(24) === "No", "<code>testLogicalAnd(24)</code> should return "No"");'
|
||||
testString: assert(testLogicalAnd(24) === "No");
|
||||
- text: <code>testLogicalAnd(25)</code>应返回“是”
|
||||
testString: 'assert(testLogicalAnd(25) === "Yes", "<code>testLogicalAnd(25)</code> should return "Yes"");'
|
||||
testString: assert(testLogicalAnd(25) === "Yes");
|
||||
- text: <code>testLogicalAnd(30)</code>应该返回“是”
|
||||
testString: 'assert(testLogicalAnd(30) === "Yes", "<code>testLogicalAnd(30)</code> should return "Yes"");'
|
||||
testString: assert(testLogicalAnd(30) === "Yes");
|
||||
- text: <code>testLogicalAnd(50)</code>应该返回“是”
|
||||
testString: 'assert(testLogicalAnd(50) === "Yes", "<code>testLogicalAnd(50)</code> should return "Yes"");'
|
||||
testString: assert(testLogicalAnd(50) === "Yes");
|
||||
- text: <code>testLogicalAnd(51)</code>应返回“否”
|
||||
testString: 'assert(testLogicalAnd(51) === "No", "<code>testLogicalAnd(51)</code> should return "No"");'
|
||||
testString: assert(testLogicalAnd(51) === "No");
|
||||
- text: <code>testLogicalAnd(75)</code>应返回“否”
|
||||
testString: 'assert(testLogicalAnd(75) === "No", "<code>testLogicalAnd(75)</code> should return "No"");'
|
||||
testString: assert(testLogicalAnd(75) === "No");
|
||||
- text: <code>testLogicalAnd(80)</code>应返回“否”
|
||||
testString: 'assert(testLogicalAnd(80) === "No", "<code>testLogicalAnd(80)</code> should return "No"");'
|
||||
testString: assert(testLogicalAnd(80) === "No");
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,25 +18,25 @@ localeTitle: 与逻辑或运算符的比较
|
||||
```yml
|
||||
tests:
|
||||
- text: 你应该使用<code>||</code>操作员一次
|
||||
testString: 'assert(code.match(/\|\|/g).length === 1, "You should use the <code>||</code> operator once");'
|
||||
testString: assert(code.match(/\|\|/g).length === 1);
|
||||
- text: 你应该只有一个<code>if</code>语句
|
||||
testString: 'assert(code.match(/if/g).length === 1, "You should only have one <code>if</code> statement");'
|
||||
testString: assert(code.match(/if/g).length === 1);
|
||||
- text: <code>testLogicalOr(0)</code>应返回“Outside”
|
||||
testString: 'assert(testLogicalOr(0) === "Outside", "<code>testLogicalOr(0)</code> should return "Outside"");'
|
||||
testString: assert(testLogicalOr(0) === "Outside");
|
||||
- text: <code>testLogicalOr(9)</code>应返回“Outside”
|
||||
testString: 'assert(testLogicalOr(9) === "Outside", "<code>testLogicalOr(9)</code> should return "Outside"");'
|
||||
testString: assert(testLogicalOr(9) === "Outside");
|
||||
- text: <code>testLogicalOr(10)</code>应返回“Inside”
|
||||
testString: 'assert(testLogicalOr(10) === "Inside", "<code>testLogicalOr(10)</code> should return "Inside"");'
|
||||
testString: assert(testLogicalOr(10) === "Inside");
|
||||
- text: <code>testLogicalOr(15)</code>应返回“Inside”
|
||||
testString: 'assert(testLogicalOr(15) === "Inside", "<code>testLogicalOr(15)</code> should return "Inside"");'
|
||||
testString: assert(testLogicalOr(15) === "Inside");
|
||||
- text: <code>testLogicalOr(19)</code>应该返回“Inside”
|
||||
testString: 'assert(testLogicalOr(19) === "Inside", "<code>testLogicalOr(19)</code> should return "Inside"");'
|
||||
testString: assert(testLogicalOr(19) === "Inside");
|
||||
- text: <code>testLogicalOr(20)</code>应该返回“Inside”
|
||||
testString: 'assert(testLogicalOr(20) === "Inside", "<code>testLogicalOr(20)</code> should return "Inside"");'
|
||||
testString: assert(testLogicalOr(20) === "Inside");
|
||||
- text: <code>testLogicalOr(21)</code>应该返回“Outside”
|
||||
testString: 'assert(testLogicalOr(21) === "Outside", "<code>testLogicalOr(21)</code> should return "Outside"");'
|
||||
testString: assert(testLogicalOr(21) === "Outside");
|
||||
- text: <code>testLogicalOr(25)</code>应返回“Outside”
|
||||
testString: 'assert(testLogicalOr(25) === "Outside", "<code>testLogicalOr(25)</code> should return "Outside"");'
|
||||
testString: assert(testLogicalOr(25) === "Outside");
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,15 +18,15 @@ localeTitle: 具有增强加法的复合赋值
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>a</code>应该等于<code>15</code>
|
||||
testString: 'assert(a === 15, "<code>a</code> should equal <code>15</code>");'
|
||||
testString: assert(a === 15);
|
||||
- text: <code>b</code>应该等于<code>26</code>
|
||||
testString: 'assert(b === 26, "<code>b</code> should equal <code>26</code>");'
|
||||
testString: assert(b === 26);
|
||||
- text: <code>c</code>应该等于<code>19</code>
|
||||
testString: 'assert(c === 19, "<code>c</code> should equal <code>19</code>");'
|
||||
testString: assert(c === 19);
|
||||
- text: 您应该为每个变量使用<code>+=</code>运算符
|
||||
testString: 'assert(code.match(/\+=/g).length === 3, "You should use the <code>+=</code> operator for each variable");'
|
||||
testString: assert(code.match(/\+=/g).length === 3);
|
||||
- text: 不要修改行上方的代码
|
||||
testString: 'assert(/var a = 3;/.test(code) && /var b = 17;/.test(code) && /var c = 12;/.test(code), "Do not modify the code above the line");'
|
||||
testString: assert(/var a = 3;/.test(code) && /var b = 17;/.test(code) && /var c = 12;/.test(code));
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,15 +18,15 @@ localeTitle: 具有增广划分的复合赋值
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>a</code>应该等于<code>4</code>
|
||||
testString: 'assert(a === 4, "<code>a</code> should equal <code>4</code>");'
|
||||
testString: assert(a === 4);
|
||||
- text: <code>b</code>应该等于<code>27</code>
|
||||
testString: 'assert(b === 27, "<code>b</code> should equal <code>27</code>");'
|
||||
testString: assert(b === 27);
|
||||
- text: <code>c</code>应该等于<code>3</code>
|
||||
testString: 'assert(c === 3, "<code>c</code> should equal <code>3</code>");'
|
||||
testString: assert(c === 3);
|
||||
- text: 您应该为每个变量使用<code>/=</code>运算符
|
||||
testString: 'assert(code.match(/\/=/g).length === 3, "You should use the <code>/=</code> operator for each variable");'
|
||||
testString: assert(code.match(/\/=/g).length === 3);
|
||||
- text: 不要修改行上方的代码
|
||||
testString: 'assert(/var a = 48;/.test(code) && /var b = 108;/.test(code) && /var c = 33;/.test(code), "Do not modify the code above the line");'
|
||||
testString: assert(/var a = 48;/.test(code) && /var b = 108;/.test(code) && /var c = 33;/.test(code));
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,15 +18,15 @@ localeTitle: 具有增广乘法的复合赋值
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>a</code>应该等于<code>25</code>
|
||||
testString: 'assert(a === 25, "<code>a</code> should equal <code>25</code>");'
|
||||
testString: assert(a === 25);
|
||||
- text: <code>b</code>应该等于<code>36</code>
|
||||
testString: 'assert(b === 36, "<code>b</code> should equal <code>36</code>");'
|
||||
testString: assert(b === 36);
|
||||
- text: <code>c</code>应该等于<code>46</code>
|
||||
testString: 'assert(c === 46, "<code>c</code> should equal <code>46</code>");'
|
||||
testString: assert(c === 46);
|
||||
- text: 您应该为每个变量使用<code>*=</code>运算符
|
||||
testString: 'assert(code.match(/\*=/g).length === 3, "You should use the <code>*=</code> operator for each variable");'
|
||||
testString: assert(code.match(/\*=/g).length === 3);
|
||||
- text: 不要修改行上方的代码
|
||||
testString: 'assert(/var a = 5;/.test(code) && /var b = 12;/.test(code) && /var c = 4\.6;/.test(code), "Do not modify the code above the line");'
|
||||
testString: assert(/var a = 5;/.test(code) && /var b = 12;/.test(code) && /var c = 4\.6;/.test(code));
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,15 +18,15 @@ localeTitle: 具有增广减法的复合赋值
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>a</code>应该等于<code>5</code>
|
||||
testString: 'assert(a === 5, "<code>a</code> should equal <code>5</code>");'
|
||||
testString: assert(a === 5);
|
||||
- text: <code>b</code>应该等于<code>-6</code>
|
||||
testString: 'assert(b === -6, "<code>b</code> should equal <code>-6</code>");'
|
||||
testString: assert(b === -6);
|
||||
- text: <code>c</code>应该等于<code>2</code>
|
||||
testString: 'assert(c === 2, "<code>c</code> should equal <code>2</code>");'
|
||||
testString: assert(c === 2);
|
||||
- text: 您应该为每个变量使用<code>-=</code>运算符
|
||||
testString: 'assert(code.match(/-=/g).length === 3, "You should use the <code>-=</code> operator for each variable");'
|
||||
testString: assert(code.match(/-=/g).length === 3);
|
||||
- text: 不要修改行上方的代码
|
||||
testString: 'assert(/var a = 11;/.test(code) && /var b = 9;/.test(code) && /var c = 3;/.test(code), "Do not modify the code above the line");'
|
||||
testString: assert(/var a = 11;/.test(code) && /var b = 9;/.test(code) && /var c = 3;/.test(code));
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,13 +18,13 @@ localeTitle: 用Plus运算符连接字符串
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>myStr</code>应该有一个值<code>This is the start. This is the end.</code>
|
||||
testString: 'assert(myStr === "This is the start. This is the end.", "<code>myStr</code> should have a value of <code>This is the start. This is the end.</code>");'
|
||||
testString: assert(myStr === "This is the start. This is the end.");
|
||||
- text: 使用<code>+</code>运算符构建<code>myStr</code>
|
||||
testString: 'assert(code.match(/([""]).*([""])\s*\+\s*([""]).*([""])/g).length > 1, "Use the <code>+</code> operator to build <code>myStr</code>");'
|
||||
testString: assert(code.match(/(["']).*(["'])\s*\+\s*(["']).*(["'])/g).length > 1);
|
||||
- text: 应使用<code>var</code>关键字创建<code>myStr</code> 。
|
||||
testString: 'assert(/var\s+myStr/.test(code), "<code>myStr</code> should be created using the <code>var</code> keyword.");'
|
||||
testString: assert(/var\s+myStr/.test(code));
|
||||
- text: 确保将结果分配给<code>myStr</code>变量。
|
||||
testString: 'assert(/myStr\s*=/.test(code), "Make sure to assign the result to the <code>myStr</code> variable.");'
|
||||
testString: assert(/myStr\s*=/.test(code));
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,9 +18,9 @@ localeTitle: 使用Plus Equals运算符连接字符串
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>myStr</code>应该有一个值<code>This is the first sentence. This is the second sentence.</code>
|
||||
testString: 'assert(myStr === "This is the first sentence. This is the second sentence.", "<code>myStr</code> should have a value of <code>This is the first sentence. This is the second sentence.</code>");'
|
||||
testString: assert(myStr === "This is the first sentence. This is the second sentence.");
|
||||
- text: 使用<code>+=</code>运算符构建<code>myStr</code>
|
||||
testString: 'assert(code.match(/\w\s*\+=\s*[""]/g).length > 1 && code.match(/\w\s*\=\s*[""]/g).length > 1, "Use the <code>+=</code> operator to build <code>myStr</code>");'
|
||||
testString: assert(code.match(/\w\s*\+=\s*["']/g).length > 1 && code.match(/\w\s*\=\s*["']/g).length > 1);
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,9 +18,9 @@ localeTitle: 用变量构造字符串
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>myName</code>应设置为至少3个字符长的字符串
|
||||
testString: 'assert(typeof myName !== "undefined" && myName.length > 2, "<code>myName</code> should be set to a string at least 3 characters long");'
|
||||
testString: assert(typeof myName !== 'undefined' && myName.length > 2);
|
||||
- text: 使用两个<code>+</code>运算符在其中构建<code>myStr</code> with <code>myName</code>
|
||||
testString: 'assert(code.match(/[""]\s*\+\s*myName\s*\+\s*[""]/g).length > 0, "Use two <code>+</code> operators to build <code>myStr</code> with <code>myName</code> inside it");'
|
||||
testString: assert(code.match(/["']\s*\+\s*myName\s*\+\s*["']/g).length > 0);
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,11 +18,11 @@ localeTitle: 用For循环向后计数
|
||||
```yml
|
||||
tests:
|
||||
- text: 你应该为此使用<code>for</code>循环。
|
||||
testString: 'assert(code.match(/for\s*\(/g).length > 1, "You should be using a <code>for</code> loop for this.");'
|
||||
testString: assert(code.match(/for\s*\(/g).length > 1);
|
||||
- text: 你应该使用数组方法<code>push</code> 。
|
||||
testString: 'assert(code.match(/myArray.push/), "You should be using the array method <code>push</code>.");'
|
||||
testString: assert(code.match(/myArray.push/));
|
||||
- text: '<code>myArray</code>应该等于<code>[9,7,5,3,1]</code> 。'
|
||||
testString: 'assert.deepEqual(myArray, [9,7,5,3,1], "<code>myArray</code> should equal <code>[9,7,5,3,1]</code>.");'
|
||||
testString: assert.deepEqual(myArray, [9,7,5,3,1]);
|
||||
|
||||
```
|
||||
|
||||
|
@ -19,19 +19,19 @@ localeTitle: 计数卡
|
||||
```yml
|
||||
tests:
|
||||
- text: 牌序列<code>5 Bet</code>应该返回<code>5 Bet</code>
|
||||
testString: 'assert((function(){ count = 0; cc(2);cc(3);cc(4);cc(5);var out = cc(6); if(out === "5 Bet") {return true;} return false; })(), "Cards Sequence 2, 3, 4, 5, 6 should return <code>5 Bet</code>");'
|
||||
testString: assert((function(){ count = 0; cc(2);cc(3);cc(4);cc(5);var out = cc(6); if(out === "5 Bet") {return true;} return false; })());
|
||||
- text: '卡片序列7,8,9应返回<code>0 Hold</code>'
|
||||
testString: 'assert((function(){ count = 0; cc(7);cc(8);var out = cc(9); if(out === "0 Hold") {return true;} return false; })(), "Cards Sequence 7, 8, 9 should return <code>0 Hold</code>");'
|
||||
testString: assert((function(){ count = 0; cc(7);cc(8);var out = cc(9); if(out === "0 Hold") {return true;} return false; })());
|
||||
- text: 卡序列10,J,Q,K,A应返回<code>-5 Hold</code>
|
||||
testString: 'assert((function(){ count = 0; cc(10);cc("J");cc("Q");cc("K");var out = cc("A"); if(out === "-5 Hold") {return true;} return false; })(), "Cards Sequence 10, J, Q, K, A should return <code>-5 Hold</code>");'
|
||||
testString: assert((function(){ count = 0; cc(10);cc('J');cc('Q');cc('K');var out = cc('A'); if(out === "-5 Hold") {return true;} return false; })());
|
||||
- text: '卡序列3,7,Q,8,A应返回<code>-1 Hold</code>'
|
||||
testString: 'assert((function(){ count = 0; cc(3);cc(7);cc("Q");cc(8);var out = cc("A"); if(out === "-1 Hold") {return true;} return false; })(), "Cards Sequence 3, 7, Q, 8, A should return <code>-1 Hold</code>");'
|
||||
testString: assert((function(){ count = 0; cc(3);cc(7);cc('Q');cc(8);var out = cc('A'); if(out === "-1 Hold") {return true;} return false; })());
|
||||
- text: 牌序列2,J, <code>1 Bet</code>应该返回<code>1 Bet</code>
|
||||
testString: 'assert((function(){ count = 0; cc(2);cc("J");cc(9);cc(2);var out = cc(7); if(out === "1 Bet") {return true;} return false; })(), "Cards Sequence 2, J, 9, 2, 7 should return <code>1 Bet</code>");'
|
||||
testString: assert((function(){ count = 0; cc(2);cc('J');cc(9);cc(2);var out = cc(7); if(out === "1 Bet") {return true;} return false; })());
|
||||
- text: 牌序列<code>1 Bet</code>应该返回<code>1 Bet</code>
|
||||
testString: 'assert((function(){ count = 0; cc(2);cc(2);var out = cc(10); if(out === "1 Bet") {return true;} return false; })(), "Cards Sequence 2, 2, 10 should return <code>1 Bet</code>");'
|
||||
testString: assert((function(){ count = 0; cc(2);cc(2);var out = cc(10); if(out === "1 Bet") {return true;} return false; })());
|
||||
- text: '卡序列3,2,A,10,K应返回<code>-1 Hold</code>'
|
||||
testString: 'assert((function(){ count = 0; cc(3);cc(2);cc("A");cc(10);var out = cc("K"); if(out === "-1 Hold") {return true;} return false; })(), "Cards Sequence 3, 2, A, 10, K should return <code>-1 Hold</code>");'
|
||||
testString: assert((function(){ count = 0; cc(3);cc(2);cc('A');cc(10);var out = cc('K'); if(out === "-1 Hold") {return true;} return false; })());
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,9 +18,9 @@ localeTitle: 使用JavaScript创建十进制数
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>myDecimal</code>应该是一个数字。
|
||||
testString: 'assert(typeof myDecimal === "number", "<code>myDecimal</code> should be a number.");'
|
||||
testString: assert(typeof myDecimal === "number");
|
||||
- text: <code>myDecimal</code>应该有一个小数点
|
||||
testString: 'assert(myDecimal % 1 != 0, "<code>myDecimal</code> should have a decimal point"); '
|
||||
testString: assert(myDecimal % 1 != 0);
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,7 +18,7 @@ localeTitle: 声明JavaScript变量
|
||||
```yml
|
||||
tests:
|
||||
- text: 您应该使用<code>var</code>关键字声明<code>myName</code> ,以分号结尾
|
||||
testString: 'assert(/var\s+myName\s*;/.test(code), "You should declare <code>myName</code> with the <code>var</code> keyword, ending with a semicolon");'
|
||||
testString: assert(/var\s+myName\s*;/.test(code));
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,9 +18,9 @@ localeTitle: 声明字符串变量
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>myFirstName</code>应该是一个至少包含一个字符的字符串。
|
||||
testString: 'assert((function(){if(typeof myFirstName !== "undefined" && typeof myFirstName === "string" && myFirstName.length > 0){return true;}else{return false;}})(), "<code>myFirstName</code> should be a string with at least one character in it.");'
|
||||
testString: assert((function(){if(typeof myFirstName !== "undefined" && typeof myFirstName === "string" && myFirstName.length > 0){return true;}else{return false;}})());
|
||||
- text: <code>myLastName</code>应该是一个至少包含一个字符的字符串。
|
||||
testString: 'assert((function(){if(typeof myLastName !== "undefined" && typeof myLastName === "string" && myLastName.length > 0){return true;}else{return false;}})(), "<code>myLastName</code> should be a string with at least one character in it.");'
|
||||
testString: assert((function(){if(typeof myLastName !== "undefined" && typeof myLastName === "string" && myLastName.length > 0){return true;}else{return false;}})());
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,13 +18,13 @@ localeTitle: 使用JavaScript减少数字
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>myVar</code>应该等于<code>10</code>
|
||||
testString: 'assert(myVar === 10, "<code>myVar</code> should equal <code>10</code>");'
|
||||
testString: assert(myVar === 10);
|
||||
- text: <code>myVar = myVar - 1;</code>应该改变
|
||||
testString: 'assert(/var\s*myVar\s*=\s*11;\s*\/*.*\s*([-]{2}\s*myVar|myVar\s*[-]{2});/.test(code), "<code>myVar = myVar - 1;</code> should be changed");'
|
||||
testString: assert(/var\s*myVar\s*=\s*11;\s*\/*.*\s*([-]{2}\s*myVar|myVar\s*[-]{2});/.test(code));
|
||||
- text: 在<code>myVar</code>上使用<code>--</code>运算符
|
||||
testString: 'assert(/[-]{2}\s*myVar|myVar\s*[-]{2}/.test(code), "Use the <code>--</code> operator on <code>myVar</code>");'
|
||||
testString: assert(/[-]{2}\s*myVar|myVar\s*[-]{2}/.test(code));
|
||||
- text: 不要更改行上方的代码
|
||||
testString: 'assert(/var myVar = 11;/.test(code), "Do not change code above the line");'
|
||||
testString: assert(/var myVar = 11;/.test(code));
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,9 +18,9 @@ localeTitle: 从JavaScript对象中删除属性
|
||||
```yml
|
||||
tests:
|
||||
- text: 从<code>myDog</code>删除属性<code>"tails"</code> 。
|
||||
testString: 'assert(typeof myDog === "object" && myDog.tails === undefined, "Delete the property <code>"tails"</code> from <code>myDog</code>.");'
|
||||
testString: assert(typeof myDog === "object" && myDog.tails === undefined);
|
||||
- text: 不要修改<code>myDog</code>设置
|
||||
testString: 'assert(code.match(/"tails": 1/g).length > 1, "Do not modify the <code>myDog</code> setup");'
|
||||
testString: 'assert(code.match(/"tails": 1/g).length > 1);'
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,11 +18,11 @@ localeTitle: 使用JavaScript将另一个十进制除以另一个
|
||||
```yml
|
||||
tests:
|
||||
- text: 变<code>quotient</code>应该等于<code>2.2</code>
|
||||
testString: 'assert(quotient === 2.2, "The variable <code>quotient</code> should equal <code>2.2</code>");'
|
||||
testString: assert(quotient === 2.2);
|
||||
- text: 您应该使用<code>/</code>运算符将4.4除以2
|
||||
testString: 'assert(/4\.40*\s*\/\s*2\.*0*/.test(code), "You should use the <code>/</code> operator to divide 4.4 by 2");'
|
||||
testString: assert(/4\.40*\s*\/\s*2\.*0*/.test(code));
|
||||
- text: 商数变量只应分配一次
|
||||
testString: 'assert(code.match(/quotient/g).length === 1, "The quotient variable should only be assigned once");'
|
||||
testString: assert(code.match(/quotient/g).length === 1);
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,9 +18,9 @@ localeTitle: 用JavaScript划分一个号码
|
||||
```yml
|
||||
tests:
|
||||
- text: 使变量<code>quotient</code>等于2。
|
||||
testString: 'assert(quotient === 2, "Make the variable <code>quotient</code> equal to 2.");'
|
||||
testString: assert(quotient === 2);
|
||||
- text: 使用<code>/</code>运算符
|
||||
testString: 'assert(/\d+\s*\/\s*\d+/.test(code), "Use the <code>/</code> operator");'
|
||||
testString: assert(/\d+\s*\/\s*\d+/.test(code));
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,9 +18,9 @@ localeTitle: 逃避字符串中的字面引用
|
||||
```yml
|
||||
tests:
|
||||
- text: 您应该使用两个双引号( <code>"</code> )和四个转义双引号( <code>\"</code> )。
|
||||
testString: 'assert(code.match(/\\"/g).length === 4 && code.match(/[^\\]"/g).length === 2, "You should use two double quotes (<code>"</code>) and four escaped double quotes (<code>\"</code>).");'
|
||||
testString: assert(code.match(/\\"/g).length === 4 && code.match(/[^\\]"/g).length === 2);
|
||||
- text: 变量myStr应该包含字符串: <code>I am a "double quoted" string inside "double quotes".</code>
|
||||
testString: 'assert(myStr === "I am a \"double quoted\" string inside \"double quotes\".", "Variable myStr should contain the string: <code>I am a "double quoted" string inside "double quotes".</code>");'
|
||||
testString: 'assert(myStr === "I am a \"double quoted\" string inside \"double quotes\".");'
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,11 +18,11 @@ localeTitle: 在JavaScript中查找剩余内容
|
||||
```yml
|
||||
tests:
|
||||
- text: 应该初始化变量<code>remainder</code>
|
||||
testString: 'assert(/var\s+?remainder/.test(code), "The variable <code>remainder</code> should be initialized");'
|
||||
testString: assert(/var\s+?remainder/.test(code));
|
||||
- text: <code>remainder</code>的值应为<code>2</code>
|
||||
testString: 'assert(remainder === 2, "The value of <code>remainder</code> should be <code>2</code>");'
|
||||
testString: assert(remainder === 2);
|
||||
- text: 您应该使用<code>%</code>运算符
|
||||
testString: 'assert(/\s+?remainder\s*?=\s*?.*%.*;/.test(code), "You should use the <code>%</code> operator");'
|
||||
testString: assert(/\s+?remainder\s*?=\s*?.*%.*;/.test(code));
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,11 +18,11 @@ localeTitle: 使用JavaScript生成随机分数
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>randomFraction</code>应该返回一个随机数。
|
||||
testString: 'assert(typeof randomFraction() === "number", "<code>randomFraction</code> should return a random number.");'
|
||||
testString: assert(typeof randomFraction() === "number");
|
||||
- text: <code>randomFraction</code>返回的<code>randomFraction</code>应该是小数。
|
||||
testString: 'assert((randomFraction()+""). match(/\./g), "The number returned by <code>randomFraction</code> should be a decimal.");'
|
||||
testString: assert((randomFraction()+''). match(/\./g));
|
||||
- text: 您应该使用<code>Math.random</code>来生成随机十进制数。
|
||||
testString: 'assert(code.match(/Math\.random/g).length >= 0, "You should be using <code>Math.random</code> to generate the random decimal number.");'
|
||||
testString: assert(code.match(/Math\.random/g).length >= 0);
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,13 +18,13 @@ localeTitle: 使用JavaScript生成随机整数
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>randomWholeNum</code>的结果应该是整数。
|
||||
testString: 'assert(typeof randomWholeNum() === "number" && (function(){var r = randomWholeNum();return Math.floor(r) === r;})(), "The result of <code>randomWholeNum</code> should be a whole number.");'
|
||||
testString: assert(typeof randomWholeNum() === "number" && (function(){var r = randomWholeNum();return Math.floor(r) === r;})());
|
||||
- text: 您应该使用<code>Math.random</code>来生成随机数。
|
||||
testString: 'assert(code.match(/Math.random/g).length > 1, "You should be using <code>Math.random</code> to generate a random number.");'
|
||||
testString: assert(code.match(/Math.random/g).length > 1);
|
||||
- text: 您应该将<code>Math.random</code>的结果乘以10,使其成为介于0和9之间的数字。
|
||||
testString: 'assert(code.match(/\s*?Math.random\s*?\(\s*?\)\s*?\*\s*?10[\D]\s*?/g) || code.match(/\s*?10\s*?\*\s*?Math.random\s*?\(\s*?\)\s*?/g), "You should have multiplied the result of <code>Math.random</code> by 10 to make it a number that is between zero and nine.");'
|
||||
testString: assert(code.match(/\s*?Math.random\s*?\(\s*?\)\s*?\*\s*?10[\D]\s*?/g) || code.match(/\s*?10\s*?\*\s*?Math.random\s*?\(\s*?\)\s*?/g));
|
||||
- text: 您应该使用<code>Math.floor</code>删除数字的小数部分。
|
||||
testString: 'assert(code.match(/Math.floor/g).length > 1, "You should use <code>Math.floor</code> to remove the decimal part of the number.");'
|
||||
testString: assert(code.match(/Math.floor/g).length > 1);
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,13 +18,13 @@ localeTitle: 生成范围内的随机整数
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>randomRange</code>可以生成的最低随机数应该等于你的最小数量<code>myMin</code> 。
|
||||
testString: 'assert(calcMin === 5, "The lowest random number that can be generated by <code>randomRange</code> should be equal to your minimum number, <code>myMin</code>.");'
|
||||
testString: assert(calcMin === 5);
|
||||
- text: <code>randomRange</code>可以生成的最高随机数应该等于最大数量<code>myMax</code> 。
|
||||
testString: 'assert(calcMax === 15, "The highest random number that can be generated by <code>randomRange</code> should be equal to your maximum number, <code>myMax</code>.");'
|
||||
testString: assert(calcMax === 15);
|
||||
- text: <code>randomRange</code>生成的随机数应该是整数,而不是小数。
|
||||
testString: 'assert(randomRange(0,1) % 1 === 0 , "The random number generated by <code>randomRange</code> should be an integer, not a decimal.");'
|
||||
testString: assert(randomRange(0,1) % 1 === 0 );
|
||||
- text: <code>randomRange</code>应该同时使用<code>myMax</code>和<code>myMin</code> ,并在你的范围内返回一个随机数。
|
||||
testString: 'assert((function(){if(code.match(/myMax/g).length > 1 && code.match(/myMin/g).length > 2 && code.match(/Math.floor/g) && code.match(/Math.random/g)){return true;}else{return false;}})(), "<code>randomRange</code> should use both <code>myMax</code> and <code>myMin</code>, and return a random number in your range.");'
|
||||
testString: assert((function(){if(code.match(/myMax/g).length > 1 && code.match(/myMin/g).length > 2 && code.match(/Math.floor/g) && code.match(/Math.random/g)){return true;}else{return false;}})());
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,13 +18,13 @@ localeTitle: 全球范围和职能
|
||||
```yml
|
||||
tests:
|
||||
- text: 应该定义<code>myGlobal</code>
|
||||
testString: 'assert(typeof myGlobal != "undefined", "<code>myGlobal</code> should be defined");'
|
||||
testString: assert(typeof myGlobal != "undefined");
|
||||
- text: <code>myGlobal</code>的值应为<code>10</code>
|
||||
testString: 'assert(myGlobal === 10, "<code>myGlobal</code> should have a value of <code>10</code>");'
|
||||
testString: assert(myGlobal === 10);
|
||||
- text: 应使用<code>var</code>关键字声明<code>myGlobal</code>
|
||||
testString: 'assert(/var\s+myGlobal/.test(code), "<code>myGlobal</code> should be declared using the <code>var</code> keyword");'
|
||||
testString: assert(/var\s+myGlobal/.test(code));
|
||||
- text: <code>oopsGlobal</code>应该是一个全局变量,其值为<code>5</code>
|
||||
testString: 'assert(typeof oopsGlobal != "undefined" && oopsGlobal === 5, "<code>oopsGlobal</code> should be a global variable and have a value of <code>5</code>");'
|
||||
testString: assert(typeof oopsGlobal != "undefined" && oopsGlobal === 5);
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,11 +18,11 @@ localeTitle: 功能中的全局与局部范围
|
||||
```yml
|
||||
tests:
|
||||
- text: 不要更改全局<code>outerWear</code>的值
|
||||
testString: 'assert(outerWear === "T-Shirt", "Do not change the value of the global <code>outerWear</code>");'
|
||||
testString: assert(outerWear === "T-Shirt");
|
||||
- text: <code>myOutfit</code>应该返回<code>"sweater"</code>
|
||||
testString: 'assert(myOutfit() === "sweater", "<code>myOutfit</code> should return <code>"sweater"</code>");'
|
||||
testString: assert(myOutfit() === "sweater");
|
||||
- text: 不要更改return语句
|
||||
testString: 'assert(/return outerWear/.test(code), "Do not change the return statement");'
|
||||
testString: assert(/return outerWear/.test(code));
|
||||
|
||||
```
|
||||
|
||||
|
@ -19,27 +19,27 @@ localeTitle: 高尔夫码
|
||||
```yml
|
||||
tests:
|
||||
- text: '<code>golfScore(4, 1)</code>应该返回“Hole-in-one!”'
|
||||
testString: 'assert(golfScore(4, 1) === "Hole-in-one!", "<code>golfScore(4, 1)</code> should return "Hole-in-one!"");'
|
||||
testString: assert(golfScore(4, 1) === "Hole-in-one!");
|
||||
- text: '<code>golfScore(4, 2)</code>应该返回“Eagle”'
|
||||
testString: 'assert(golfScore(4, 2) === "Eagle", "<code>golfScore(4, 2)</code> should return "Eagle"");'
|
||||
testString: assert(golfScore(4, 2) === "Eagle");
|
||||
- text: '<code>golfScore(5, 2)</code>应该返回“Eagle”'
|
||||
testString: 'assert(golfScore(5, 2) === "Eagle", "<code>golfScore(5, 2)</code> should return "Eagle"");'
|
||||
testString: assert(golfScore(5, 2) === "Eagle");
|
||||
- text: '<code>golfScore(4, 3)</code>应该返回“Birdie”'
|
||||
testString: 'assert(golfScore(4, 3) === "Birdie", "<code>golfScore(4, 3)</code> should return "Birdie"");'
|
||||
testString: assert(golfScore(4, 3) === "Birdie");
|
||||
- text: '<code>golfScore(4, 4)</code>应该返回“Par”'
|
||||
testString: 'assert(golfScore(4, 4) === "Par", "<code>golfScore(4, 4)</code> should return "Par"");'
|
||||
testString: assert(golfScore(4, 4) === "Par");
|
||||
- text: '<code>golfScore(1, 1)</code>应该返回“Hole-in-one!”'
|
||||
testString: 'assert(golfScore(1, 1) === "Hole-in-one!", "<code>golfScore(1, 1)</code> should return "Hole-in-one!"");'
|
||||
testString: assert(golfScore(1, 1) === "Hole-in-one!");
|
||||
- text: '<code>golfScore(5, 5)</code>应该返回“Par”'
|
||||
testString: 'assert(golfScore(5, 5) === "Par", "<code>golfScore(5, 5)</code> should return "Par"");'
|
||||
testString: assert(golfScore(5, 5) === "Par");
|
||||
- text: '<code>golfScore(4, 5)</code>应该返回“Bogey”'
|
||||
testString: 'assert(golfScore(4, 5) === "Bogey", "<code>golfScore(4, 5)</code> should return "Bogey"");'
|
||||
testString: assert(golfScore(4, 5) === "Bogey");
|
||||
- text: '<code>golfScore(4, 6)</code>应该返回“Double Bogey”'
|
||||
testString: 'assert(golfScore(4, 6) === "Double Bogey", "<code>golfScore(4, 6)</code> should return "Double Bogey"");'
|
||||
testString: assert(golfScore(4, 6) === "Double Bogey");
|
||||
- text: '<code>golfScore(4, 7)</code>应该返回“Go Home!”'
|
||||
testString: 'assert(golfScore(4, 7) === "Go Home!", "<code>golfScore(4, 7)</code> should return "Go Home!"");'
|
||||
testString: assert(golfScore(4, 7) === "Go Home!");
|
||||
- text: '<code>golfScore(5, 9)</code>应该返回“Go Home!”'
|
||||
testString: 'assert(golfScore(5, 9) === "Go Home!", "<code>golfScore(5, 9)</code> should return "Go Home!"");'
|
||||
testString: assert(golfScore(5, 9) === "Go Home!");
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,13 +18,13 @@ localeTitle: 使用JavaScript增加数字
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>myVar</code>应该等于<code>88</code>
|
||||
testString: 'assert(myVar === 88, "<code>myVar</code> should equal <code>88</code>");'
|
||||
testString: assert(myVar === 88);
|
||||
- text: <code>myVar = myVar + 1;</code>应该改变
|
||||
testString: 'assert(/var\s*myVar\s*=\s*87;\s*\/*.*\s*([+]{2}\s*myVar|myVar\s*[+]{2});/.test(code), "<code>myVar = myVar + 1;</code> should be changed");'
|
||||
testString: assert(/var\s*myVar\s*=\s*87;\s*\/*.*\s*([+]{2}\s*myVar|myVar\s*[+]{2});/.test(code));
|
||||
- text: 使用<code>++</code>运算符
|
||||
testString: 'assert(/[+]{2}\s*myVar|myVar\s*[+]{2}/.test(code), "Use the <code>++</code> operator");'
|
||||
testString: assert(/[+]{2}\s*myVar|myVar\s*[+]{2}/.test(code));
|
||||
- text: 不要更改行上方的代码
|
||||
testString: 'assert(/var myVar = 87;/.test(code), "Do not change code above the line");'
|
||||
testString: assert(/var myVar = 87;/.test(code));
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,7 +18,7 @@ localeTitle: 使用赋值运算符初始化变量
|
||||
```yml
|
||||
tests:
|
||||
- text: 将<code>a</code>初始化为值<code>9</code>
|
||||
testString: 'assert(/var\s+a\s*=\s*9\s*/.test(code), "Initialize <code>a</code> to a value of <code>9</code>");'
|
||||
testString: assert(/var\s+a\s*=\s*9\s*/.test(code));
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,21 +18,21 @@ localeTitle: 如果声明引入Else
|
||||
```yml
|
||||
tests:
|
||||
- text: 你应该至少有两个<code>else</code>语句
|
||||
testString: 'assert(code.match(/else/g).length > 1, "You should have at least two <code>else</code> statements");'
|
||||
testString: assert(code.match(/else/g).length > 1);
|
||||
- text: 你应该至少有两个<code>if</code>语句
|
||||
testString: 'assert(code.match(/if/g).length > 1, "You should have at least two <code>if</code> statements");'
|
||||
testString: assert(code.match(/if/g).length > 1);
|
||||
- text: 您应该为每个条件关闭并打开花括号
|
||||
testString: 'assert(code.match(/if\s*\((.+)\)\s*\{[\s\S]+\}\s*else if\s*\((.+)\)\s*\{[\s\S]+\}\s*else\s*\{[\s\S]+\s*\}/), "You should have closing and opening curly braces for each condition in your if else statement");'
|
||||
testString: assert(code.match(/if\s*\((.+)\)\s*\{[\s\S]+\}\s*else if\s*\((.+)\)\s*\{[\s\S]+\}\s*else\s*\{[\s\S]+\s*\}/));
|
||||
- text: <code>testElseIf(0)</code>应返回“小于5”
|
||||
testString: 'assert(testElseIf(0) === "Smaller than 5", "<code>testElseIf(0)</code> should return "Smaller than 5"");'
|
||||
testString: assert(testElseIf(0) === "Smaller than 5");
|
||||
- text: <code>testElseIf(5)</code>应该返回“5到10之间”
|
||||
testString: 'assert(testElseIf(5) === "Between 5 and 10", "<code>testElseIf(5)</code> should return "Between 5 and 10"");'
|
||||
testString: assert(testElseIf(5) === "Between 5 and 10");
|
||||
- text: <code>testElseIf(7)</code>应返回“5到10之间”
|
||||
testString: 'assert(testElseIf(7) === "Between 5 and 10", "<code>testElseIf(7)</code> should return "Between 5 and 10"");'
|
||||
testString: assert(testElseIf(7) === "Between 5 and 10");
|
||||
- text: <code>testElseIf(10)</code>应返回“5到10之间”
|
||||
testString: 'assert(testElseIf(10) === "Between 5 and 10", "<code>testElseIf(10)</code> should return "Between 5 and 10"");'
|
||||
testString: assert(testElseIf(10) === "Between 5 and 10");
|
||||
- text: <code>testElseIf(12)</code>应返回“大于10”
|
||||
testString: 'assert(testElseIf(12) === "Greater than 10", "<code>testElseIf(12)</code> should return "Greater than 10"");'
|
||||
testString: assert(testElseIf(12) === "Greater than 10");
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,19 +18,19 @@ localeTitle: 介绍其他声明
|
||||
```yml
|
||||
tests:
|
||||
- text: 您应该只在编辑器中有一个<code>if</code>语句
|
||||
testString: 'assert(code.match(/if/g).length === 1, "You should only have one <code>if</code> statement in the editor");'
|
||||
testString: assert(code.match(/if/g).length === 1);
|
||||
- text: 你应该使用<code>else</code>语句
|
||||
testString: 'assert(/else/g.test(code), "You should use an <code>else</code> statement");'
|
||||
testString: assert(/else/g.test(code));
|
||||
- text: <code>testElse(4)</code>应返回“5或更小”
|
||||
testString: 'assert(testElse(4) === "5 or Smaller", "<code>testElse(4)</code> should return "5 or Smaller"");'
|
||||
testString: assert(testElse(4) === "5 or Smaller");
|
||||
- text: <code>testElse(5)</code>应返回“5或更小”
|
||||
testString: 'assert(testElse(5) === "5 or Smaller", "<code>testElse(5)</code> should return "5 or Smaller"");'
|
||||
testString: assert(testElse(5) === "5 or Smaller");
|
||||
- text: <code>testElse(6)</code>应该返回“大于5”
|
||||
testString: 'assert(testElse(6) === "Bigger than 5", "<code>testElse(6)</code> should return "Bigger than 5"");'
|
||||
testString: assert(testElse(6) === "Bigger than 5");
|
||||
- text: <code>testElse(10)</code>应该返回“大于5”
|
||||
testString: 'assert(testElse(10) === "Bigger than 5", "<code>testElse(10)</code> should return "Bigger than 5"");'
|
||||
testString: assert(testElse(10) === "Bigger than 5");
|
||||
- text: 请勿更改行上方或下方的代码。
|
||||
testString: 'assert(/var result = "";/.test(code) && /return result;/.test(code), "Do not change the code above or below the lines.");'
|
||||
testString: assert(/var result = "";/.test(code) && /return result;/.test(code));
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,9 +18,9 @@ localeTitle: 使用For循环迭代奇数
|
||||
```yml
|
||||
tests:
|
||||
- text: 你应该为此使用<code>for</code>循环。
|
||||
testString: 'assert(code.match(/for\s*\(/g).length > 1, "You should be using a <code>for</code> loop for this.");'
|
||||
testString: assert(code.match(/for\s*\(/g).length > 1);
|
||||
- text: '<code>myArray</code>应该等于<code>[1,3,5,7,9]</code> 。'
|
||||
testString: 'assert.deepEqual(myArray, [1,3,5,7,9], "<code>myArray</code> should equal <code>[1,3,5,7,9]</code>.");'
|
||||
testString: assert.deepEqual(myArray, [1,3,5,7,9]);
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,13 +18,13 @@ localeTitle: 使用For循环遍历数组
|
||||
```yml
|
||||
tests:
|
||||
- text: 应声明<code>total</code>并初始化为0
|
||||
testString: 'assert(code.match(/var.*?total\s*=\s*0.*?;/), "<code>total</code> should be declared and initialized to 0");'
|
||||
testString: assert(code.match(/(var|let|const)\s*?total\s*=\s*0.*?;?/));
|
||||
- text: <code>total</code>应该等于20
|
||||
testString: 'assert(total === 20, "<code>total</code> should equal 20");'
|
||||
testString: assert(total === 20);
|
||||
- text: 您应该使用<code>for</code>循环来遍历<code>myArr</code>
|
||||
testString: 'assert(code.match(/for\s*\(/g).length > 1 && code.match(/myArr\s*\[/), "You should use a <code>for</code> loop to iterate through <code>myArr</code>");'
|
||||
testString: assert(code.match(/for\s*\(/g).length > 1 && code.match(/myArr\s*\[/));
|
||||
- text: 不要直接将<code>total</code>设置为20
|
||||
testString: 'assert(!code.match(/total[\s\+\-]*=\s*(\d(?!\s*[;,])|[1-9])/g), "Do not set <code>total</code> to 20 directly");'
|
||||
testString: assert(!code.replace(/\s/g, '').match(/total[=+-]0*[1-9]+/gm));
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,11 +18,11 @@ localeTitle: 使用JavaScript迭代...循环
|
||||
```yml
|
||||
tests:
|
||||
- text: 你应该使用<code>do...while</code>循环。
|
||||
testString: 'assert(code.match(/do/g), "You should be using a <code>do...while</code> loop for this.");'
|
||||
testString: assert(code.match(/do/g));
|
||||
- text: '<code>myArray</code>应该等于<code>[10]</code> 。'
|
||||
testString: 'assert.deepEqual(myArray, [10], "<code>myArray</code> should equal <code>[10]</code>.");'
|
||||
testString: assert.deepEqual(myArray, [10]);
|
||||
- text: <code>i</code>应该等于<code>11</code>
|
||||
testString: 'assert.deepEqual(i, 11, "<code>i</code> should equal <code>11</code>");'
|
||||
testString: assert.equal(i, 11);
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,9 +18,9 @@ localeTitle: 使用JavaScript迭代循环
|
||||
```yml
|
||||
tests:
|
||||
- text: 你应该为此使用<code>for</code>循环。
|
||||
testString: 'assert(code.match(/for\s*\(/g).length > 1, "You should be using a <code>for</code> loop for this.");'
|
||||
testString: assert(code.match(/for\s*\(/g).length > 1);
|
||||
- text: '<code>myArray</code>应该等于<code>[1,2,3,4,5]</code> 。'
|
||||
testString: 'assert.deepEqual(myArray, [1,2,3,4,5], "<code>myArray</code> should equal <code>[1,2,3,4,5]</code>.");'
|
||||
testString: assert.deepEqual(myArray, [1,2,3,4,5]);
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,9 +18,9 @@ localeTitle: 在循环时使用JavaScript进行迭代
|
||||
```yml
|
||||
tests:
|
||||
- text: 你应该使用<code>while</code>循环。
|
||||
testString: 'assert(code.match(/while/g), "You should be using a <code>while</code> loop for this.");'
|
||||
testString: assert(code.match(/while/g));
|
||||
- text: '<code>myArray</code>应该等于<code>[0,1,2,3,4]</code> 。'
|
||||
testString: 'assert.deepEqual(myArray, [0,1,2,3,4], "<code>myArray</code> should equal <code>[0,1,2,3,4]</code>.");'
|
||||
testString: assert.deepEqual(myArray, [5,4,3,2,1,0]);
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,9 +18,9 @@ localeTitle: 本地范围和功能
|
||||
```yml
|
||||
tests:
|
||||
- text: 没有全局<code>myVar</code>变量
|
||||
testString: 'assert(typeof myVar === "undefined", "No global <code>myVar</code> variable");'
|
||||
testString: assert(typeof myVar === 'undefined');
|
||||
- text: 添加本地<code>myVar</code>变量
|
||||
testString: 'assert(/var\s+myVar/.test(code), "Add a local <code>myVar</code> variable");'
|
||||
testString: assert(/function\s+myLocalScope\s*\(\s*\)\s*\{\s[\s\S]+\s*var\s*myVar\s*(\s*|=[\s\S]+)\s*;[\s\S]+}/.test(code));
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,11 +18,11 @@ localeTitle: 如果其他陈述中的逻辑顺序
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>orderMyLogic(4)</code>应返回“小于5”
|
||||
testString: 'assert(orderMyLogic(4) === "Less than 5", "<code>orderMyLogic(4)</code> should return "Less than 5"");'
|
||||
testString: assert(orderMyLogic(4) === "Less than 5");
|
||||
- text: <code>orderMyLogic(6)</code>应该返回“少于10”
|
||||
testString: 'assert(orderMyLogic(6) === "Less than 10", "<code>orderMyLogic(6)</code> should return "Less than 10"");'
|
||||
testString: assert(orderMyLogic(6) === "Less than 10");
|
||||
- text: <code>orderMyLogic(11)</code>应该返回“大于或等于10”
|
||||
testString: 'assert(orderMyLogic(11) === "Greater than or equal to 10", "<code>orderMyLogic(11)</code> should return "Greater than or equal to 10"");'
|
||||
testString: assert(orderMyLogic(11) === "Greater than or equal to 10");
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,11 +18,11 @@ localeTitle: 使用pop()操作数组
|
||||
```yml
|
||||
tests:
|
||||
- text: '<code>myArray</code>应该只包含<code>[["John", 23]]</code> 。'
|
||||
testString: 'assert((function(d){if(d[0][0] == "John" && d[0][1] === 23 && d[1] == undefined){return true;}else{return false;}})(myArray), "<code>myArray</code> should only contain <code>[["John", 23]]</code>.");'
|
||||
testString: assert((function(d){if(d[0][0] == 'John' && d[0][1] === 23 && d[1] == undefined){return true;}else{return false;}})(myArray));
|
||||
- text: 在<code>myArray</code>上使用<code>pop()</code>
|
||||
testString: 'assert(/removedFromMyArray\s*=\s*myArray\s*.\s*pop\s*(\s*)/.test(code), "Use <code>pop()</code> on <code>myArray</code>");'
|
||||
testString: assert(/removedFromMyArray\s*=\s*myArray\s*.\s*pop\s*(\s*)/.test(code));
|
||||
- text: '<code>removedFromMyArray</code>应该只包含<code>["cat", 2]</code> 。'
|
||||
testString: 'assert((function(d){if(d[0] == "cat" && d[1] === 2 && d[2] == undefined){return true;}else{return false;}})(removedFromMyArray), "<code>removedFromMyArray</code> should only contain <code>["cat", 2]</code>.");'
|
||||
testString: assert((function(d){if(d[0] == 'cat' && d[1] === 2 && d[2] == undefined){return true;}else{return false;}})(removedFromMyArray));
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,7 +18,7 @@ localeTitle: 用push()操纵数组
|
||||
```yml
|
||||
tests:
|
||||
- text: '<code>myArray</code>现在应该等于<code>[["John", 23], ["cat", 2], ["dog", 3]]</code> 。'
|
||||
testString: 'assert((function(d){if(d[2] != undefined && d[0][0] == "John" && d[0][1] === 23 && d[2][0] == "dog" && d[2][1] === 3 && d[2].length == 2){return true;}else{return false;}})(myArray), "<code>myArray</code> should now equal <code>[["John", 23], ["cat", 2], ["dog", 3]]</code>.");'
|
||||
testString: assert((function(d){if(d[2] != undefined && d[0][0] == 'John' && d[0][1] === 23 && d[2][0] == 'dog' && d[2][1] === 3 && d[2].length == 2){return true;}else{return false;}})(myArray));
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,9 +18,9 @@ localeTitle: 使用shift()操纵数组
|
||||
```yml
|
||||
tests:
|
||||
- text: '<code>myArray</code>现在应该等于<code>[["dog", 3]]</code> 。'
|
||||
testString: 'assert((function(d){if(d[0][0] == "dog" && d[0][1] === 3 && d[1] == undefined){return true;}else{return false;}})(myArray), "<code>myArray</code> should now equal <code>[["dog", 3]]</code>.");'
|
||||
testString: assert((function(d){if(d[0][0] == 'dog' && d[0][1] === 3 && d[1] == undefined){return true;}else{return false;}})(myArray));
|
||||
- text: '<code>removedFromMyArray</code>应该包含<code>["John", 23]</code> 。'
|
||||
testString: 'assert((function(d){if(d[0] == "John" && d[1] === 23 && typeof removedFromMyArray === "object"){return true;}else{return false;}})(removedFromMyArray), "<code>removedFromMyArray</code> should contain <code>["John", 23]</code>.");'
|
||||
testString: assert((function(d){if(d[0] == 'John' && d[1] === 23 && typeof removedFromMyArray === 'object'){return true;}else{return false;}})(removedFromMyArray));
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,7 +18,7 @@ localeTitle: 使用unshift操作数组()
|
||||
```yml
|
||||
tests:
|
||||
- text: '<code>myArray</code>现在应该有[[“Paul”,35],[“dog”,3]]。'
|
||||
testString: 'assert((function(d){if(typeof d[0] === "object" && d[0][0] == "Paul" && d[0][1] === 35 && d[1][0] != undefined && d[1][0] == "dog" && d[1][1] != undefined && d[1][1] == 3){return true;}else{return false;}})(myArray), "<code>myArray</code> should now have [["Paul", 35], ["dog", 3]].");'
|
||||
testString: assert((function(d){if(typeof d[0] === "object" && d[0][0] == 'Paul' && d[0][1] === 35 && d[1][0] != undefined && d[1][0] == 'dog' && d[1][1] != undefined && d[1][1] == 3){return true;}else{return false;}})(myArray));
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,23 +18,23 @@ localeTitle: 操纵复杂对象
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>myMusic</code>应该是一个数组
|
||||
testString: 'assert(Array.isArray(myMusic), "<code>myMusic</code> should be an array");'
|
||||
testString: assert(Array.isArray(myMusic));
|
||||
- text: <code>myMusic</code>应该至少有两个元素
|
||||
testString: 'assert(myMusic.length > 1, "<code>myMusic</code> should have at least two elements");'
|
||||
testString: assert(myMusic.length > 1);
|
||||
- text: '<code>myMusic[1]</code>应该是一个对象'
|
||||
testString: 'assert(typeof myMusic[1] === "object", "<code>myMusic[1]</code> should be an object");'
|
||||
testString: assert(typeof myMusic[1] === 'object');
|
||||
- text: '<code>myMusic[1]</code>应该至少有4个属性'
|
||||
testString: 'assert(Object.keys(myMusic[1]).length > 3, "<code>myMusic[1]</code> should have at least 4 properties");'
|
||||
testString: assert(Object.keys(myMusic[1]).length > 3);
|
||||
- text: '<code>myMusic[1]</code>应该包含一个<code>artist</code>属性,它是一个字符串'
|
||||
testString: 'assert(myMusic[1].hasOwnProperty("artist") && typeof myMusic[1].artist === "string", "<code>myMusic[1]</code> should contain an <code>artist</code> property which is a string");'
|
||||
testString: assert(myMusic[1].hasOwnProperty('artist') && typeof myMusic[1].artist === 'string');
|
||||
- text: '<code>myMusic[1]</code>应该包含一个<code>title</code>属性,它是一个字符串'
|
||||
testString: 'assert(myMusic[1].hasOwnProperty("title") && typeof myMusic[1].title === "string", "<code>myMusic[1]</code> should contain a <code>title</code> property which is a string");'
|
||||
testString: assert(myMusic[1].hasOwnProperty('title') && typeof myMusic[1].title === 'string');
|
||||
- text: '<code>myMusic[1]</code>应该包含一个<code>release_year</code>属性,它是一个数字'
|
||||
testString: 'assert(myMusic[1].hasOwnProperty("release_year") && typeof myMusic[1].release_year === "number", "<code>myMusic[1]</code> should contain a <code>release_year</code> property which is a number");'
|
||||
testString: assert(myMusic[1].hasOwnProperty('release_year') && typeof myMusic[1].release_year === 'number');
|
||||
- text: '<code>myMusic[1]</code>应该包含一个<code>formats</code>属性,它是一个数组'
|
||||
testString: 'assert(myMusic[1].hasOwnProperty("formats") && Array.isArray(myMusic[1].formats), "<code>myMusic[1]</code> should contain a <code>formats</code> property which is an array");'
|
||||
testString: assert(myMusic[1].hasOwnProperty('formats') && Array.isArray(myMusic[1].formats));
|
||||
- text: <code>formats</code>应该是一个至少包含两个元素的字符串数组
|
||||
testString: 'assert(myMusic[1].formats.every(function(item) { return (typeof item === "string")}) && myMusic[1].formats.length > 1, "<code>formats</code> should be an array of strings with at least two elements");'
|
||||
testString: assert(myMusic[1].formats.every(function(item) { return (typeof item === "string")}) && myMusic[1].formats.length > 1);
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,9 +18,9 @@ localeTitle: 使用索引修改数组数据
|
||||
```yml
|
||||
tests:
|
||||
- text: '<code>myArray</code>现在应该是[45,64,99]。'
|
||||
testString: 'assert((function(){if(typeof myArray != "undefined" && myArray[0] == 45 && myArray[1] == 64 && myArray[2] == 99){return true;}else{return false;}})(), "<code>myArray</code> should now be [45,64,99].");'
|
||||
testString: assert((function(){if(typeof myArray != 'undefined' && myArray[0] == 45 && myArray[1] == 64 && myArray[2] == 99){return true;}else{return false;}})());
|
||||
- text: 您应该使用正确的索引来修改<code>myArray</code>的值。
|
||||
testString: 'assert((function(){if(code.match(/myArray\[0\]\s*=\s*/g)){return true;}else{return false;}})(), "You should be using correct index to modify the value in <code>myArray</code>.");'
|
||||
testString: assert((function(){if(code.match(/myArray\[0\]\s*=\s*/g)){return true;}else{return false;}})());
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,27 +18,27 @@ localeTitle: 交换机语句中的多个相同选项
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>sequentialSizes(1)</code>应返回“Low”
|
||||
testString: 'assert(sequentialSizes(1) === "Low", "<code>sequentialSizes(1)</code> should return "Low"");'
|
||||
testString: assert(sequentialSizes(1) === "Low");
|
||||
- text: <code>sequentialSizes(2)</code>应该返回“Low”
|
||||
testString: 'assert(sequentialSizes(2) === "Low", "<code>sequentialSizes(2)</code> should return "Low"");'
|
||||
testString: assert(sequentialSizes(2) === "Low");
|
||||
- text: <code>sequentialSizes(3)</code>应返回“Low”
|
||||
testString: 'assert(sequentialSizes(3) === "Low", "<code>sequentialSizes(3)</code> should return "Low"");'
|
||||
testString: assert(sequentialSizes(3) === "Low");
|
||||
- text: <code>sequentialSizes(4)</code>应返回“Mid”
|
||||
testString: 'assert(sequentialSizes(4) === "Mid", "<code>sequentialSizes(4)</code> should return "Mid"");'
|
||||
testString: assert(sequentialSizes(4) === "Mid");
|
||||
- text: <code>sequentialSizes(5)</code>应返回“Mid”
|
||||
testString: 'assert(sequentialSizes(5) === "Mid", "<code>sequentialSizes(5)</code> should return "Mid"");'
|
||||
testString: assert(sequentialSizes(5) === "Mid");
|
||||
- text: <code>sequentialSizes(6)</code>应返回“Mid”
|
||||
testString: 'assert(sequentialSizes(6) === "Mid", "<code>sequentialSizes(6)</code> should return "Mid"");'
|
||||
testString: assert(sequentialSizes(6) === "Mid");
|
||||
- text: <code>sequentialSizes(7)</code>应该返回“High”
|
||||
testString: 'assert(sequentialSizes(7) === "High", "<code>sequentialSizes(7)</code> should return "High"");'
|
||||
testString: assert(sequentialSizes(7) === "High");
|
||||
- text: <code>sequentialSizes(8)</code>应该返回“High”
|
||||
testString: 'assert(sequentialSizes(8) === "High", "<code>sequentialSizes(8)</code> should return "High"");'
|
||||
testString: assert(sequentialSizes(8) === "High");
|
||||
- text: <code>sequentialSizes(9)</code>应该返回“High”
|
||||
testString: 'assert(sequentialSizes(9) === "High", "<code>sequentialSizes(9)</code> should return "High"");'
|
||||
testString: assert(sequentialSizes(9) === "High");
|
||||
- text: 您不应该使用任何<code>if</code>或<code>else</code>语句
|
||||
testString: 'assert(!/else/g.test(code) || !/if/g.test(code), "You should not use any <code>if</code> or <code>else</code> statements");'
|
||||
testString: assert(!/else/g.test(code) || !/if/g.test(code));
|
||||
- text: 你应该有九个<code>case</code>陈述
|
||||
testString: 'assert(code.match(/case/g).length === 9, "You should have nine <code>case</code> statements");'
|
||||
testString: assert(code.match(/case/g).length === 9);
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,9 +18,9 @@ localeTitle: 使用JavaScript乘以两个小数
|
||||
```yml
|
||||
tests:
|
||||
- text: 变量<code>product</code>应该等于<code>5.0</code> 。
|
||||
testString: 'assert(product === 5.0, "The variable <code>product</code> should equal <code>5.0</code>.");'
|
||||
testString: assert(product === 5.0);
|
||||
- text: 你应该使用<code>*</code>运算符
|
||||
testString: 'assert(/\*/.test(code), "You should use the <code>*</code> operator");'
|
||||
testString: assert(/\*/.test(code));
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,9 +18,9 @@ localeTitle: 使用JavaScript将两个数字相乘
|
||||
```yml
|
||||
tests:
|
||||
- text: 使变量<code>product</code>等于80
|
||||
testString: 'assert(product === 80,"Make the variable <code>product</code> equal 80");'
|
||||
testString: assert(product === 80);
|
||||
- text: 使用<code>*</code>运算符
|
||||
testString: 'assert(/\*/.test(code), "Use the <code>*</code> operator");'
|
||||
testString: assert(/\*/.test(code));
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,7 +18,7 @@ localeTitle: 将一个Array嵌套在另一个Array中
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>myArray</code>应至少有一个嵌套在另一个数组中的数组。
|
||||
testString: 'assert(Array.isArray(myArray) && myArray.some(Array.isArray), "<code>myArray</code> should have at least one array nested within another array.");'
|
||||
testString: assert(Array.isArray(myArray) && myArray.some(Array.isArray));
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,11 +18,11 @@ localeTitle: 嵌套循环
|
||||
```yml
|
||||
tests:
|
||||
- text: '<code>multiplyAll([[1],[2],[3]])</code>应该返回<code>6</code>'
|
||||
testString: 'assert(multiplyAll([[1],[2],[3]]) === 6, "<code>multiplyAll([[1],[2],[3]])</code> should return <code>6</code>");'
|
||||
testString: assert(multiplyAll([[1],[2],[3]]) === 6);
|
||||
- text: '<code>multiplyAll([[1,2],[3,4],[5,6,7]])</code>应返回<code>5040</code>'
|
||||
testString: 'assert(multiplyAll([[1,2],[3,4],[5,6,7]]) === 5040, "<code>multiplyAll([[1,2],[3,4],[5,6,7]])</code> should return <code>5040</code>");'
|
||||
testString: assert(multiplyAll([[1,2],[3,4],[5,6,7]]) === 5040);
|
||||
- text: '<code>multiplyAll([[5,1],[0.2, 4, 0.5],[3, 9]])</code>应该返回<code>54</code>'
|
||||
testString: 'assert(multiplyAll([[5,1],[0.2, 4, 0.5],[3, 9]]) === 54, "<code>multiplyAll([[5,1],[0.2, 4, 0.5],[3, 9]])</code> should return <code>54</code>");'
|
||||
testString: assert(multiplyAll([[5,1],[0.2, 4, 0.5],[3, 9]]) === 54);
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,13 +18,13 @@ localeTitle: 将值传递给带参数的函数
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>functionWithArgs</code>应该是一个函数
|
||||
testString: 'assert(typeof functionWithArgs === "function", "<code>functionWithArgs</code> should be a function");'
|
||||
testString: assert(typeof functionWithArgs === 'function');
|
||||
- text: '<code>functionWithArgs(1,2)</code>应该输出<code>3</code>'
|
||||
testString: 'if(typeof functionWithArgs === "function") { capture(); functionWithArgs(1,2); uncapture(); } assert(logOutput == 3, "<code>functionWithArgs(1,2)</code> should output <code>3</code>");'
|
||||
testString: if(typeof functionWithArgs === "function") { capture(); functionWithArgs(1,2); uncapture(); } assert(logOutput == 3);
|
||||
- text: '<code>functionWithArgs(7,9)</code>应该输出<code>16</code>'
|
||||
testString: 'if(typeof functionWithArgs === "function") { capture(); functionWithArgs(7,9); uncapture(); } assert(logOutput == 16, "<code>functionWithArgs(7,9)</code> should output <code>16</code>");'
|
||||
testString: if(typeof functionWithArgs === "function") { capture(); functionWithArgs(7,9); uncapture(); } assert(logOutput == 16);
|
||||
- text: 定义后,使用两个数字调用<code>functionWithArgs</code> 。
|
||||
testString: 'assert(/^\s*functionWithArgs\s*\(\s*\d+\s*,\s*\d+\s*\)\s*;/m.test(code), "Call <code>functionWithArgs</code> with two numbers after you define it.");'
|
||||
testString: assert(/^\s*functionWithArgs\s*\(\s*\d+\s*,\s*\d+\s*\)\s*/m.test(code));
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,11 +18,11 @@ localeTitle: 练习比较不同的值
|
||||
```yml
|
||||
tests:
|
||||
- text: '<code>compareEquality(10, "10")</code>应返回“Not Equal”'
|
||||
testString: 'assert(compareEquality(10, "10") === "Not Equal", "<code>compareEquality(10, "10")</code> should return "Not Equal"");'
|
||||
testString: assert(compareEquality(10, "10") === "Not Equal");
|
||||
- text: '<code>compareEquality("20", 20)</code>应该返回“Not Equal”'
|
||||
testString: 'assert(compareEquality("20", 20) === "Not Equal", "<code>compareEquality("20", 20)</code> should return "Not Equal"");'
|
||||
testString: assert(compareEquality("20", 20) === "Not Equal");
|
||||
- text: 您应该使用<code>===</code>运算符
|
||||
testString: 'assert(code.match(/===/g), "You should use the <code>===</code> operator");'
|
||||
testString: assert(code.match(/===/g));
|
||||
|
||||
```
|
||||
|
||||
|
@ -19,17 +19,17 @@ localeTitle: 个人资料查询
|
||||
```yml
|
||||
tests:
|
||||
- text: '<code>"Kristian", "lastName"</code>应该返回<code>"Vos"</code>'
|
||||
testString: 'assert(lookUpProfile("Kristian","lastName") === "Vos", "<code>"Kristian", "lastName"</code> should return <code>"Vos"</code>");'
|
||||
testString: assert(lookUpProfile('Kristian','lastName') === "Vos");
|
||||
- text: '<code>"Sherlock", "likes"</code>应该回归<code>["Intriguing Cases", "Violin"]</code>'
|
||||
testString: 'assert.deepEqual(lookUpProfile("Sherlock", "likes"), ["Intriguing Cases", "Violin"], "<code>"Sherlock", "likes"</code> should return <code>["Intriguing Cases", "Violin"]</code>");'
|
||||
testString: assert.deepEqual(lookUpProfile("Sherlock", "likes"), ["Intriguing Cases", "Violin"]);
|
||||
- text: '<code>"Harry","likes"</code>应该返回一个阵列'
|
||||
testString: 'assert(typeof lookUpProfile("Harry", "likes") === "object", "<code>"Harry","likes"</code> should return an array");'
|
||||
testString: assert(typeof lookUpProfile("Harry", "likes") === "object");
|
||||
- text: '<code>"Bob", "number"</code>应该返回“没有这样的联系”'
|
||||
testString: 'assert(lookUpProfile("Bob", "number") === "No such contact", "<code>"Bob", "number"</code> should return "No such contact"");'
|
||||
testString: assert(lookUpProfile("Bob", "number") === "No such contact");
|
||||
- text: '<code>"Bob", "potato"</code>应该返回“没有这样的联系”'
|
||||
testString: 'assert(lookUpProfile("Bob", "potato") === "No such contact", "<code>"Bob", "potato"</code> should return "No such contact"");'
|
||||
testString: assert(lookUpProfile("Bob", "potato") === "No such contact");
|
||||
- text: '<code>"Akira", "address"</code>应该返回“没有这样的财产”'
|
||||
testString: 'assert(lookUpProfile("Akira", "address") === "No such property", "<code>"Akira", "address"</code> should return "No such property"");'
|
||||
testString: assert(lookUpProfile("Akira", "address") === "No such property");
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,9 +18,9 @@ localeTitle: 单引号引用字符串
|
||||
```yml
|
||||
tests:
|
||||
- text: 删除所有<code>backslashes</code> ( <code>\</code> )
|
||||
testString: 'assert(!/\\/g.test(code) && myStr.match("\\s*<a href\\s*=\\s*"http://www.example.com"\\s*target\\s*=\\s*"_blank">\\s*Link\\s*</a>\\s*"), "Remove all the <code>backslashes</code> (<code>\</code>)");'
|
||||
testString: assert(!/\\/g.test(code) && myStr.match('\\s*<a href\\s*=\\s*"http://www.example.com"\\s*target\\s*=\\s*"_blank">\\s*Link\\s*</a>\\s*'));
|
||||
- text: '你应该有两个单引号<code>'</code>和四个双引号<code>"</code>'
|
||||
testString: 'assert(code.match(/"/g).length === 4 && code.match(/"/g).length === 2, "You should have two single quotes <code>'</code> and four double quotes <code>"</code>");'
|
||||
testString: assert(code.match(/"/g).length === 4 && code.match(/'/g).length === 2);
|
||||
|
||||
```
|
||||
|
||||
|
@ -19,19 +19,19 @@ localeTitle: 记录收集
|
||||
```yml
|
||||
tests:
|
||||
- text: '在<code>updateRecords(5439, "artist", "ABBA")</code> , <code>artist</code>应该是<code>"ABBA"</code>'
|
||||
testString: 'collection = collectionCopy; assert(updateRecords(5439, "artist", "ABBA")[5439]["artist"] === "ABBA", "After <code>updateRecords(5439, "artist", "ABBA")</code>, <code>artist</code> should be <code>"ABBA"</code>");'
|
||||
testString: collection = collectionCopy; assert(updateRecords(5439, "artist", "ABBA")[5439]["artist"] === "ABBA");
|
||||
- text: '在<code>updateRecords(5439, "tracks", "Take a Chance on Me")</code> , <code>tracks</code>应该以<code>"Take a Chance on Me"</code>作为最后一个元素。'
|
||||
testString: 'assert(updateRecords(5439, "tracks", "Take a Chance on Me")[5439]["tracks"].pop() === "Take a Chance on Me", "After <code>updateRecords(5439, "tracks", "Take a Chance on Me")</code>, <code>tracks</code> should have <code>"Take a Chance on Me"</code> as the last element.");'
|
||||
testString: assert(updateRecords(5439, "tracks", "Take a Chance on Me")[5439]["tracks"].pop() === "Take a Chance on Me");
|
||||
- text: '在<code>updateRecords(2548, "artist", "")</code> ,不应该设置<code>artist</code>'
|
||||
testString: 'updateRecords(2548, "artist", ""); assert(!collection[2548].hasOwnProperty("artist"), "After <code>updateRecords(2548, "artist", "")</code>, <code>artist</code> should not be set");'
|
||||
testString: updateRecords(2548, "artist", ""); assert(!collection[2548].hasOwnProperty("artist"));
|
||||
- text: '在<code>updateRecords(1245, "tracks", "Addicted to Love")</code> , <code>tracks</code>应该将<code>"Addicted to Love"</code>作为最后一个元素。'
|
||||
testString: 'assert(updateRecords(1245, "tracks", "Addicted to Love")[1245]["tracks"].pop() === "Addicted to Love", "After <code>updateRecords(1245, "tracks", "Addicted to Love")</code>, <code>tracks</code> should have <code>"Addicted to Love"</code> as the last element.");'
|
||||
testString: assert(updateRecords(1245, "tracks", "Addicted to Love")[1245]["tracks"].pop() === "Addicted to Love");
|
||||
- text: '在<code>updateRecords(2468, "tracks", "Free")</code> , <code>tracks</code>应该以<code>"1999"</code>作为第一个元素。'
|
||||
testString: 'assert(updateRecords(2468, "tracks", "Free")[2468]["tracks"][0] === "1999", "After <code>updateRecords(2468, "tracks", "Free")</code>, <code>tracks</code> should have <code>"1999"</code> as the first element.");'
|
||||
testString: assert(updateRecords(2468, "tracks", "Free")[2468]["tracks"][0] === "1999");
|
||||
- text: '在<code>updateRecords(2548, "tracks", "")</code> ,不应设置<code>tracks</code>'
|
||||
testString: 'updateRecords(2548, "tracks", ""); assert(!collection[2548].hasOwnProperty("tracks"), "After <code>updateRecords(2548, "tracks", "")</code>, <code>tracks</code> should not be set");'
|
||||
testString: updateRecords(2548, "tracks", ""); assert(!collection[2548].hasOwnProperty("tracks"));
|
||||
- text: '在<code>updateRecords(1245, "album", "Riptide")</code> , <code>album</code>应该是<code>"Riptide"</code>'
|
||||
testString: 'assert(updateRecords(1245, "album", "Riptide")[1245]["album"] === "Riptide", "After <code>updateRecords(1245, "album", "Riptide")</code>, <code>album</code> should be <code>"Riptide"</code>");'
|
||||
testString: assert(updateRecords(1245, "album", "Riptide")[1245]["album"] === "Riptide");
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,25 +18,25 @@ localeTitle: 如果用交换机替换其他链条
|
||||
```yml
|
||||
tests:
|
||||
- text: 您不应该在编辑器中的任何位置使用任何<code>else</code>语句
|
||||
testString: 'assert(!/else/g.test(code), "You should not use any <code>else</code> statements anywhere in the editor");'
|
||||
testString: assert(!/else/g.test(code));
|
||||
- text: 您不应在编辑器中的任何位置使用任何<code>if</code>语句
|
||||
testString: 'assert(!/if/g.test(code), "You should not use any <code>if</code> statements anywhere in the editor");'
|
||||
testString: assert(!/if/g.test(code));
|
||||
- text: 你应该至少有四个<code>break</code>语句
|
||||
testString: 'assert(code.match(/break/g).length >= 4, "You should have at least four <code>break</code> statements");'
|
||||
testString: assert(code.match(/break/g).length >= 4);
|
||||
- text: <code>chainToSwitch("bob")</code>应该是“Marley”
|
||||
testString: 'assert(chainToSwitch("bob") === "Marley", "<code>chainToSwitch("bob")</code> should be "Marley"");'
|
||||
testString: assert(chainToSwitch("bob") === "Marley");
|
||||
- text: <code>chainToSwitch(42)</code>应该是“答案”
|
||||
testString: 'assert(chainToSwitch(42) === "The Answer", "<code>chainToSwitch(42)</code> should be "The Answer"");'
|
||||
testString: assert(chainToSwitch(42) === "The Answer");
|
||||
- text: <code>chainToSwitch(1)</code>应该是“没有#1”
|
||||
testString: 'assert(chainToSwitch(1) === "There is no #1", "<code>chainToSwitch(1)</code> should be "There is no #1"");'
|
||||
testString: "assert(chainToSwitch(1) === \"There is no #1\");"
|
||||
- text: <code>chainToSwitch(99)</code>应该是“错过了我这么多!”
|
||||
testString: 'assert(chainToSwitch(99) === "Missed me by this much!", "<code>chainToSwitch(99)</code> should be "Missed me by this much!"");'
|
||||
testString: assert(chainToSwitch(99) === "Missed me by this much!");
|
||||
- text: <code>chainToSwitch(7)</code>应该是“Ate Nine”
|
||||
testString: 'assert(chainToSwitch(7) === "Ate Nine", "<code>chainToSwitch(7)</code> should be "Ate Nine"");'
|
||||
testString: assert(chainToSwitch(7) === "Ate Nine");
|
||||
- text: <code>chainToSwitch("John")</code>应为“”(空字符串)
|
||||
testString: 'assert(chainToSwitch("John") === "", "<code>chainToSwitch("John")</code> should be "" (empty string)");'
|
||||
testString: assert(chainToSwitch("John") === "");
|
||||
- text: <code>chainToSwitch(156)</code>应为“”(空字符串)
|
||||
testString: 'assert(chainToSwitch(156) === "", "<code>chainToSwitch(156)</code> should be "" (empty string)");'
|
||||
testString: assert(chainToSwitch(156) === "");
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,13 +18,13 @@ localeTitle: 从带返回的函数返回值
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>timesFive</code>应该是一个功能
|
||||
testString: 'assert(typeof timesFive === "function", "<code>timesFive</code> should be a function");'
|
||||
testString: assert(typeof timesFive === 'function');
|
||||
- text: <code>timesFive(5)</code>应该返回<code>25</code>
|
||||
testString: 'assert(timesFive(5) === 25, "<code>timesFive(5)</code> should return <code>25</code>");'
|
||||
testString: assert(timesFive(5) === 25);
|
||||
- text: <code>timesFive(2)</code>应该返回<code>10</code>
|
||||
testString: 'assert(timesFive(2) === 10, "<code>timesFive(2)</code> should return <code>10</code>");'
|
||||
testString: assert(timesFive(2) === 10);
|
||||
- text: <code>timesFive(0)</code>应该返回<code>0</code>
|
||||
testString: 'assert(timesFive(0) === 0, "<code>timesFive(0)</code> should return <code>0</code>");'
|
||||
testString: assert(timesFive(0) === 0);
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,17 +18,17 @@ localeTitle: 返回函数的早期模式
|
||||
```yml
|
||||
tests:
|
||||
- text: '<code>abTest(2,2)</code>应返回一个数字'
|
||||
testString: 'assert(typeof abTest(2,2) === "number" , "<code>abTest(2,2)</code> should return a number");'
|
||||
testString: assert(typeof abTest(2,2) === 'number' );
|
||||
- text: '<code>abTest(2,2)</code>应该返回<code>8</code>'
|
||||
testString: 'assert(abTest(2,2) === 8 , "<code>abTest(2,2)</code> should return <code>8</code>");'
|
||||
testString: assert(abTest(2,2) === 8 );
|
||||
- text: '<code>abTest(-2,2)</code>应返回<code>undefined</code>'
|
||||
testString: 'assert(abTest(-2,2) === undefined , "<code>abTest(-2,2)</code> should return <code>undefined</code>");'
|
||||
testString: assert(abTest(-2,2) === undefined );
|
||||
- text: '<code>abTest(2,-2)</code>应返回<code>undefined</code>'
|
||||
testString: 'assert(abTest(2,-2) === undefined , "<code>abTest(2,-2)</code> should return <code>undefined</code>");'
|
||||
testString: assert(abTest(2,-2) === undefined );
|
||||
- text: '<code>abTest(2,8)</code>应该返回<code>18</code>'
|
||||
testString: 'assert(abTest(2,8) === 18 , "<code>abTest(2,8)</code> should return <code>18</code>");'
|
||||
testString: assert(abTest(2,8) === 18 );
|
||||
- text: '<code>abTest(3,3)</code>应该返回<code>12</code>'
|
||||
testString: 'assert(abTest(3,3) === 12 , "<code>abTest(3,3)</code> should return <code>12</code>");'
|
||||
testString: assert(abTest(3,3) === 12 );
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,11 +18,11 @@ localeTitle: 从函数返回布尔值
|
||||
```yml
|
||||
tests:
|
||||
- text: '<code>isLess(10,15)</code>应该返回<code>true</code>'
|
||||
testString: 'assert(isLess(10,15) === true, "<code>isLess(10,15)</code> should return <code>true</code>");'
|
||||
testString: assert(isLess(10,15) === true);
|
||||
- text: '<code>isLess(15,10)</code>应该返回<code>false</code>'
|
||||
testString: 'assert(isLess(15, 10) === false, "<code>isLess(15,10)</code> should return <code>false</code>");'
|
||||
testString: assert(isLess(15, 10) === false);
|
||||
- text: 您不应该使用任何<code>if</code>或<code>else</code>语句
|
||||
testString: 'assert(!/if|else/g.test(code), "You should not use any <code>if</code> or <code>else</code> statements");'
|
||||
testString: assert(!/if|else/g.test(code));
|
||||
|
||||
```
|
||||
|
||||
|
@ -7,7 +7,25 @@ localeTitle: 从带有开关语句的多个选项中进行选择
|
||||
---
|
||||
|
||||
## Description
|
||||
undefined
|
||||
<section id="description">
|
||||
|
||||
如果您有很多选择,请使用<dfn> switch </dfn>语句。 <code> switch </code>语句测试一个值,并且可以包含许多定义各种可能值的<dfn> case </dfn>语句。 从第一个匹配的<code> case </code>值开始执行语句,直到遇到<code> break </code>。
|
||||
这是<code> switch </code>语句的示例:
|
||||
|
||||
```js
|
||||
switch(lowercaseLetter) {
|
||||
case "a":
|
||||
console.log("A");
|
||||
break;
|
||||
case "b":
|
||||
console.log("B");
|
||||
break;
|
||||
}
|
||||
```
|
||||
|
||||
<code> case </code>值以严格相等性(<code> === </code>)进行测试。 <code> break </code>告诉JavaScript停止执行语句。 如果省略<code> break </code>,将执行下一条语句。
|
||||
|
||||
</section>
|
||||
|
||||
## Instructions
|
||||
<section id="instructions">编写一个switch语句,测试<code>val</code>并设置以下条件的<code>answer</code> : <br> <code>1</code> - “alpha” <br> <code>2</code> - “beta” <br> <code>3</code> - “伽玛” <br> <code>4</code> - “三角洲” </section>
|
||||
@ -18,17 +36,17 @@ undefined
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>caseInSwitch(1)</code>的值应为“alpha”
|
||||
testString: 'assert(caseInSwitch(1) === "alpha", "<code>caseInSwitch(1)</code> should have a value of "alpha"");'
|
||||
testString: assert(caseInSwitch(1) === "alpha");
|
||||
- text: <code>caseInSwitch(2)</code>的值应为“beta”
|
||||
testString: 'assert(caseInSwitch(2) === "beta", "<code>caseInSwitch(2)</code> should have a value of "beta"");'
|
||||
testString: assert(caseInSwitch(2) === "beta");
|
||||
- text: <code>caseInSwitch(3)</code>的值应为“gamma”
|
||||
testString: 'assert(caseInSwitch(3) === "gamma", "<code>caseInSwitch(3)</code> should have a value of "gamma"");'
|
||||
testString: assert(caseInSwitch(3) === "gamma");
|
||||
- text: <code>caseInSwitch(4)</code>的值应为“delta”
|
||||
testString: 'assert(caseInSwitch(4) === "delta", "<code>caseInSwitch(4)</code> should have a value of "delta"");'
|
||||
testString: assert(caseInSwitch(4) === "delta");
|
||||
- text: 您不应该使用任何<code>if</code>或<code>else</code>语句
|
||||
testString: 'assert(!/else/g.test(code) || !/if/g.test(code), "You should not use any <code>if</code> or <code>else</code> statements");'
|
||||
testString: assert(!/else/g.test(code) || !/if/g.test(code));
|
||||
- text: 你应该至少有3个<code>break</code>语句
|
||||
testString: 'assert(code.match(/break/g).length > 2, "You should have at least 3 <code>break</code> statements");'
|
||||
testString: assert(code.match(/break/g).length > 2);
|
||||
|
||||
```
|
||||
|
||||
|
@ -19,13 +19,13 @@ localeTitle: 购物清单
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>myList</code>应该是一个数组
|
||||
testString: 'assert(isArray, "<code>myList</code> should be an array");'
|
||||
testString: assert(isArray);
|
||||
- text: 每个子数组中的第一个元素都必须是字符串
|
||||
testString: 'assert(hasString, "The first elements in each of your sub-arrays must all be strings");'
|
||||
testString: assert(hasString);
|
||||
- text: 每个子数组中的第二个元素都必须是数字
|
||||
testString: 'assert(hasNumber, "The second elements in each of your sub-arrays must all be numbers");'
|
||||
testString: assert(hasNumber);
|
||||
- text: 您的列表中必须至少有5个项目
|
||||
testString: 'assert(count > 4, "You must have at least 5 items in your list");'
|
||||
testString: assert(count > 4);
|
||||
|
||||
```
|
||||
|
||||
|
@ -19,15 +19,15 @@ localeTitle: 站在队中
|
||||
```yml
|
||||
tests:
|
||||
- text: '<code>nextInLine([], 5)</code>应返回一个数字。'
|
||||
testString: 'assert.isNumber(nextInLine([],5), "<code>nextInLine([], 5)</code> should return a number.");'
|
||||
testString: assert.isNumber(nextInLine([],5));
|
||||
- text: '<code>nextInLine([], 1)</code>应该返回<code>1</code>'
|
||||
testString: 'assert(nextInLine([],1) === 1, "<code>nextInLine([], 1)</code> should return <code>1</code>");'
|
||||
testString: assert(nextInLine([],1) === 1);
|
||||
- text: '<code>nextInLine([2], 1)</code>应返回<code>2</code>'
|
||||
testString: 'assert(nextInLine([2],1) === 2, "<code>nextInLine([2], 1)</code> should return <code>2</code>");'
|
||||
testString: assert(nextInLine([2],1) === 2);
|
||||
- text: '<code>nextInLine([5,6,7,8,9], 1)</code>应该返回<code>5</code>'
|
||||
testString: 'assert(nextInLine([5,6,7,8,9],1) === 5, "<code>nextInLine([5,6,7,8,9], 1)</code> should return <code>5</code>");'
|
||||
testString: assert(nextInLine([5,6,7,8,9],1) === 5);
|
||||
- text: '在<code>nextInLine(testArr, 10)</code> , <code>testArr[4]</code>应为<code>10</code>'
|
||||
testString: 'nextInLine(testArr, 10); assert(testArr[4] === 10, "After <code>nextInLine(testArr, 10)</code>, <code>testArr[4]</code> should be <code>10</code>");'
|
||||
testString: nextInLine(testArr, 10); assert(testArr[4] === 10);
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,11 +18,11 @@ localeTitle: 使用JavaScript数组在一个变量中存储多个值
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>myArray</code>应该是一个<code>array</code> 。
|
||||
testString: 'assert(typeof myArray == "object", "<code>myArray</code> should be an <code>array</code>.");'
|
||||
testString: assert(typeof myArray == 'object');
|
||||
- text: <code>myArray</code>的第一项应该是一个<code>string</code> 。
|
||||
testString: 'assert(typeof myArray[0] !== "undefined" && typeof myArray[0] == "string", "The first item in <code>myArray</code> should be a <code>string</code>.");'
|
||||
testString: assert(typeof myArray[0] !== 'undefined' && typeof myArray[0] == 'string');
|
||||
- text: <code>myArray</code>的第二项应该是一个<code>number</code> 。
|
||||
testString: 'assert(typeof myArray[1] !== "undefined" && typeof myArray[1] == "number", "The second item in <code>myArray</code> should be a <code>number</code>.");'
|
||||
testString: assert(typeof myArray[1] !== 'undefined' && typeof myArray[1] == 'number');
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,13 +18,13 @@ localeTitle: 使用赋值运算符存储值
|
||||
```yml
|
||||
tests:
|
||||
- text: 不要更改行上方的代码
|
||||
testString: 'assert(/var a;/.test(code) && /var b = 2;/.test(code), "Do not change code above the line");'
|
||||
testString: assert(/var a;/.test(code) && /var b = 2;/.test(code));
|
||||
- text: <code>a</code>的值应为7
|
||||
testString: 'assert(typeof a === "number" && a === 7, "<code>a</code> should have a value of 7");'
|
||||
testString: assert(typeof a === 'number' && a === 7);
|
||||
- text: <code>b</code>的值应为7
|
||||
testString: 'assert(typeof b === "number" && b === 7, "<code>b</code> should have a value of 7");'
|
||||
testString: assert(typeof b === 'number' && b === 7);
|
||||
- text: <code>a</code>应分配给<code>b</code> <code>=</code>
|
||||
testString: 'assert(/b\s*=\s*a\s*;/g.test(code), "<code>a</code> should be assigned to <code>b</code> with <code>=</code>");'
|
||||
testString: assert(/b\s*=\s*a\s*;/g.test(code));
|
||||
|
||||
```
|
||||
|
||||
|
@ -17,10 +17,10 @@ localeTitle: 使用JavaScript从另一个数字中减去一个数字
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: ''
|
||||
testString: 'assert(difference === 12, "Make the variable <code>difference</code> equal 12.");'
|
||||
- text: 使变量<code>difference</code>等于12。
|
||||
testString: assert(difference === 12);
|
||||
- text: 只从45中减去一个数字。
|
||||
testString: 'assert(/var\s*difference\s*=\s*45\s*-\s*[0-9]*;(?!\s*[a-zA-Z0-9]+)/.test(code),"Only subtract one number from 45.");'
|
||||
testString: assert(/difference=45-33;?/.test(code.replace(/\s/g, '')));
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,11 +18,11 @@ localeTitle: 测试属性的对象
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>checkObj("gift")</code>应该返回<code>"pony"</code> 。
|
||||
testString: 'assert(checkObj("gift") === "pony", "<code>checkObj("gift")</code> should return <code>"pony"</code>.");'
|
||||
testString: assert(checkObj("gift") === "pony");
|
||||
- text: <code>checkObj("pet")</code>应该返回<code>"kitten"</code> 。
|
||||
testString: 'assert(checkObj("pet") === "kitten", "<code>checkObj("pet")</code> should return <code>"kitten"</code>.");'
|
||||
testString: assert(checkObj("pet") === "kitten");
|
||||
- text: <code>checkObj("house")</code>应该返回<code>"Not Found"</code> 。
|
||||
testString: 'assert(checkObj("house") === "Not Found", "<code>checkObj("house")</code> should return <code>"Not Found"</code>.");'
|
||||
testString: assert(checkObj("house") === "Not Found");
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,9 +18,9 @@ localeTitle: 理解字符串不变性
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>myStr</code>应该具有<code>Hello World</code>的值
|
||||
testString: 'assert(myStr === "Hello World", "<code>myStr</code> should have a value of <code>Hello World</code>");'
|
||||
testString: assert(myStr === "Hello World");
|
||||
- text: 不要更改行上方的代码
|
||||
testString: 'assert(/myStr = "Jello World"/.test(code), "Do not change the code above the line");'
|
||||
testString: assert(/myStr = "Jello World"/.test(code));
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,9 +18,9 @@ localeTitle: 了解布尔值
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>welcomeToBooleans()</code>函数应该返回一个布尔值(true / false)。
|
||||
testString: 'assert(typeof welcomeToBooleans() === "boolean", "The <code>welcomeToBooleans()</code> function should return a boolean (true/false) value.");'
|
||||
testString: assert(typeof welcomeToBooleans() === 'boolean');
|
||||
- text: <code>welcomeToBooleans()</code>应该返回true。
|
||||
testString: 'assert(welcomeToBooleans() === true, "<code>welcomeToBooleans()</code> should return true.");'
|
||||
testString: assert(welcomeToBooleans() === true);
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,17 +18,17 @@ localeTitle: 了解变量中的大小写敏感度
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>studlyCapVar</code>已定义且值为<code>10</code>
|
||||
testString: 'assert(typeof studlyCapVar !== "undefined" && studlyCapVar === 10, "<code>studlyCapVar</code> is defined and has a value of <code>10</code>");'
|
||||
testString: assert(typeof studlyCapVar !== 'undefined' && studlyCapVar === 10);
|
||||
- text: <code>properCamelCase</code>已定义且值为<code>"A String"</code>
|
||||
testString: 'assert(typeof properCamelCase !== "undefined" && properCamelCase === "A String", "<code>properCamelCase</code> is defined and has a value of <code>"A String"</code>");'
|
||||
testString: assert(typeof properCamelCase !== 'undefined' && properCamelCase === "A String");
|
||||
- text: <code>titleCaseOver</code>已定义,其值为<code>9000</code>
|
||||
testString: 'assert(typeof titleCaseOver !== "undefined" && titleCaseOver === 9000, "<code>titleCaseOver</code> is defined and has a value of <code>9000</code>");'
|
||||
testString: assert(typeof titleCaseOver !== 'undefined' && titleCaseOver === 9000);
|
||||
- text: <code>studlyCapVar</code>应该在声明和赋值部分使用camelCase。
|
||||
testString: 'assert(code.match(/studlyCapVar/g).length === 2, "<code>studlyCapVar</code> should use camelCase in both declaration and assignment sections.");'
|
||||
testString: assert(code.match(/studlyCapVar/g).length === 2);
|
||||
- text: <code>properCamelCase</code>应该在声明和赋值部分使用camelCase。
|
||||
testString: 'assert(code.match(/properCamelCase/g).length === 2, "<code>properCamelCase</code> should use camelCase in both declaration and assignment sections.");'
|
||||
testString: assert(code.match(/properCamelCase/g).length === 2);
|
||||
- text: <code>titleCaseOver</code>应该在声明和赋值部分使用camelCase。
|
||||
testString: 'assert(code.match(/titleCaseOver/g).length === 2, "<code>titleCaseOver</code> should use camelCase in both declaration and assignment sections.");'
|
||||
testString: assert(code.match(/titleCaseOver/g).length === 2);
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,13 +18,13 @@ localeTitle: 了解从函数返回的未定义值
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>addFive</code>应该是一个函数
|
||||
testString: 'assert(typeof addFive === "function", "<code>addFive</code> should be a function");'
|
||||
testString: assert(typeof addFive === 'function');
|
||||
- text: <code>sum</code>应该等于8
|
||||
testString: 'assert(sum === 8, "<code>sum</code> should be equal to 8");'
|
||||
testString: assert(sum === 8);
|
||||
- text: <code>addFive</code>返回值应该是<code>undefined</code>
|
||||
testString: 'assert(addFive() === undefined, "Returned value from <code>addFive</code> should be <code>undefined</code>");'
|
||||
testString: assert(addFive() === undefined);
|
||||
- text: 在函数内部,向<code>sum</code>变量添加5
|
||||
testString: 'assert(code.match(/(sum\s*\=\s*sum\s*\+\s*5)|(sum\s*\+\=\s*5)/g).length === 1, "Inside of your functions, add 5 to the <code>sum</code> variable");'
|
||||
testString: assert(addFive.toString().replace(/\s/g, '').match(/sum=sum\+5|sum\+=5/));
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,13 +18,13 @@ localeTitle: 了解未初始化的变量
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>a</code>应定义并评估其值为<code>6</code>
|
||||
testString: 'assert(typeof a === "number" && a === 6, "<code>a</code> should be defined and evaluated to have the value of <code>6</code>");'
|
||||
testString: assert(typeof a === 'number' && a === 6);
|
||||
- text: 应定义和评估<code>b</code>的值为<code>15</code>
|
||||
testString: 'assert(typeof b === "number" && b === 15, "<code>b</code> should be defined and evaluated to have the value of <code>15</code>");'
|
||||
testString: assert(typeof b === 'number' && b === 15);
|
||||
- text: <code>c</code>不应该包含<code>undefined</code>并且值应为“我是一个字符串!”
|
||||
testString: 'assert(!/undefined/.test(c) && c === "I am a String!", "<code>c</code> should not contain <code>undefined</code> and should have a value of "I am a String!"");'
|
||||
testString: assert(!/undefined/.test(c) && c === "I am a String!");
|
||||
- text: 不要更改行下方的代码
|
||||
testString: 'assert(/a = a \+ 1;/.test(code) && /b = b \+ 5;/.test(code) && /c = c \+ " String!";/.test(code), "Do not change code below the line");'
|
||||
testString: assert(/a = a \+ 1;/.test(code) && /b = b \+ 5;/.test(code) && /c = c \+ " String!";/.test(code));
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,9 +18,9 @@ localeTitle: 更新对象属性
|
||||
```yml
|
||||
tests:
|
||||
- text: 将<code>myDog</code>的<code>"name"</code>属性更新为“Happy Coder”。
|
||||
testString: 'assert(/happy coder/gi.test(myDog.name), "Update <code>myDog</code>'s <code>"name"</code> property to equal "Happy Coder".");'
|
||||
testString: assert(/happy coder/gi.test(myDog.name));
|
||||
- text: 不要编辑<code>myDog</code>定义
|
||||
testString: 'assert(/"name": "Coder"/.test(code), "Do not edit the <code>myDog</code> definition");'
|
||||
testString: 'assert(/"name": "Coder"/.test(code));'
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,9 +18,9 @@ localeTitle: 使用括号表示法查找字符串中的第一个字符
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>firstLetterOfLastName</code>变量的值应为<code>L</code>
|
||||
testString: 'assert(firstLetterOfLastName === "L", "The <code>firstLetterOfLastName</code> variable should have the value of <code>L</code>.");'
|
||||
testString: assert(firstLetterOfLastName === 'L');
|
||||
- text: 您应该使用括号表示法。
|
||||
testString: 'assert(code.match(/firstLetterOfLastName\s*?=\s*?lastName\[.*?\]/), "You should use bracket notation.");'
|
||||
testString: assert(code.match(/firstLetterOfLastName\s*?=\s*?lastName\[.*?\]/));
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,9 +18,9 @@ localeTitle: 使用括号表示法查找字符串中的最后一个字符
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>lastLetterOfLastName</code>应为“e”。
|
||||
testString: 'assert(lastLetterOfLastName === "e", "<code>lastLetterOfLastName</code> should be "e".");'
|
||||
testString: assert(lastLetterOfLastName === "e");
|
||||
- text: 你必须使用<code>.length</code>来获取最后一个字母。
|
||||
testString: 'assert(code.match(/\.length/g).length === 2, "You have to use <code>.length</code> to get the last letter.");'
|
||||
testString: assert(code.match(/\.length/g).length === 2);
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,9 +18,9 @@ localeTitle: 使用括号表示法查找字符串中的第N个字符
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>thirdLetterOfLastName</code>变量的值应为<code>v</code> 。
|
||||
testString: 'assert(thirdLetterOfLastName === "v", "The <code>thirdLetterOfLastName</code> variable should have the value of <code>v</code>.");'
|
||||
testString: assert(thirdLetterOfLastName === 'v');
|
||||
- text: 您应该使用括号表示法。
|
||||
testString: 'assert(code.match(/thirdLetterOfLastName\s*?=\s*?lastName\[.*?\]/), "You should use bracket notation.");'
|
||||
testString: assert(code.match(/thirdLetterOfLastName\s*?=\s*?lastName\[.*?\]/));
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,9 +18,9 @@ localeTitle: 使用括号表示法查找字符串中的第N个到最后一个字
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>secondToLastLetterOfLastName</code>应为“c”。
|
||||
testString: 'assert(secondToLastLetterOfLastName === "c", "<code>secondToLastLetterOfLastName</code> should be "c".");'
|
||||
testString: assert(secondToLastLetterOfLastName === 'c');
|
||||
- text: 你必须使用<code>.length</code>来获得倒数第二个字母。
|
||||
testString: 'assert(code.match(/\.length/g).length === 2, "You have to use <code>.length</code> to get the second last letter.");'
|
||||
testString: assert(code.match(/\.length/g).length === 2);
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,15 +18,15 @@ localeTitle: 使用条件逻辑和If语句
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>trueOrFalse</code>应该是一个函数
|
||||
testString: 'assert(typeof trueOrFalse === "function", "<code>trueOrFalse</code> should be a function");'
|
||||
testString: assert(typeof trueOrFalse === "function");
|
||||
- text: <code>trueOrFalse(true)</code>应该返回一个字符串
|
||||
testString: 'assert(typeof trueOrFalse(true) === "string", "<code>trueOrFalse(true)</code> should return a string");'
|
||||
testString: assert(typeof trueOrFalse(true) === "string");
|
||||
- text: <code>trueOrFalse(false)</code>应该返回一个字符串
|
||||
testString: 'assert(typeof trueOrFalse(false) === "string", "<code>trueOrFalse(false)</code> should return a string");'
|
||||
testString: assert(typeof trueOrFalse(false) === "string");
|
||||
- text: <code>trueOrFalse(true)</code>应该返回“是的,那是真的”
|
||||
testString: 'assert(trueOrFalse(true) === "Yes, that was true", "<code>trueOrFalse(true)</code> should return "Yes, that was true"");'
|
||||
testString: assert(trueOrFalse(true) === "Yes, that was true");
|
||||
- text: <code>trueOrFalse(false)</code>应该返回“No,that was false”
|
||||
testString: 'assert(trueOrFalse(false) === "No, that was false", "<code>trueOrFalse(false)</code> should return "No, that was false"");'
|
||||
testString: assert(trueOrFalse(false) === "No, that was false");
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,13 +18,13 @@ localeTitle: 使用多个条件(三元)运算符
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>checkSign</code>应该使用多个<code>conditional operators</code>
|
||||
testString: 'assert(/.+?\s*?\?\s*?.+?\s*?:\s*?.+?\s*?\?\s*?.+?\s*?:\s*?.+?/gi.test(code), "<code>checkSign</code> should use multiple <code>conditional operators</code>");'
|
||||
testString: assert(/.+?\s*?\?\s*?.+?\s*?:\s*?.+?\s*?\?\s*?.+?\s*?:\s*?.+?/gi.test(code));
|
||||
- text: <code>checkSign(10)</code>应该返回“positive”。请注意,资本化很重要
|
||||
testString: 'assert(checkSign(10) === "positive", "<code>checkSign(10)</code> should return "positive". Note that capitalization matters");'
|
||||
testString: assert(checkSign(10) === 'positive');
|
||||
- text: <code>checkSign(-12)</code>应返回“否定”。请注意,资本化很重要
|
||||
testString: 'assert(checkSign(-12) === "negative", "<code>checkSign(-12)</code> should return "negative". Note that capitalization matters");'
|
||||
testString: assert(checkSign(-12) === 'negative');
|
||||
- text: <code>checkSign(0)</code>应返回“零”。请注意,资本化很重要
|
||||
testString: 'assert(checkSign(0) === "zero", "<code>checkSign(0)</code> should return "zero". Note that capitalization matters");'
|
||||
testString: assert(checkSign(0) === 'zero');
|
||||
|
||||
```
|
||||
|
||||
|
@ -18,13 +18,13 @@ localeTitle: 使用条件(三元)运算符
|
||||
```yml
|
||||
tests:
|
||||
- text: <code>checkEqual</code>应该使用<code>conditional operator</code>
|
||||
testString: 'assert(/.+?\s*?\?\s*?.+?\s*?:\s*?.+?/gi.test(code), "<code>checkEqual</code> should use the <code>conditional operator</code>");'
|
||||
testString: assert(/.+?\s*?\?\s*?.+?\s*?:\s*?.+?/.test(code));
|
||||
- text: '<code>checkEqual(1, 2)</code>应该返回false'
|
||||
testString: 'assert(checkEqual(1, 2) === false, "<code>checkEqual(1, 2)</code> should return false");'
|
||||
testString: assert(checkEqual(1, 2) === "Not Equal");
|
||||
- text: '<code>checkEqual(1, 1)</code>应该返回true'
|
||||
testString: 'assert(checkEqual(1, 1) === true, "<code>checkEqual(1, 1)</code> should return true");'
|
||||
testString: assert(checkEqual(1, 1) === "Equal");
|
||||
- text: '<code>checkEqual(1, -1)</code>应该返回false'
|
||||
testString: 'assert(checkEqual(1, -1) === false, "<code>checkEqual(1, -1)</code> should return false");'
|
||||
testString: assert(checkEqual(1, -1) === "Not Equal");
|
||||
|
||||
```
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user