diff --git a/02-javascript-algorithms-and-data-structures/basic-algorithm-scripting.json b/02-javascript-algorithms-and-data-structures/basic-algorithm-scripting.json index 98c48be..9bf0519 100644 --- a/02-javascript-algorithms-and-data-structures/basic-algorithm-scripting.json +++ b/02-javascript-algorithms-and-data-structures/basic-algorithm-scripting.json @@ -8,9 +8,9 @@ "id": "56533eb9ac21ba0edf2244b3", "title": "Convert Celsius to Fahrenheit", "description": [ - "The algorithm to convert from Celsius to Fahrenheit is the temperature in Celsius times 9/5, plus 32.", - "You are given a variable celsius representing a temperature in Celsius. Use the variable fahrenheit already defined and assign it the Fahrenheit temperature equivalent to the given Celsius temperature. Use the algorithm mentioned above to help convert the Celsius temperature to Fahrenheit.", - "Don't worry too much about the function and return statements as they will be covered in future challenges. For now, only use operators that you have already learned." + "将摄氏度转换为华氏度的算法为:摄氏度 × 9/5 + 32", + "输入参数 celsius 代表一个摄氏温度值。请您根据上述转换公式,将已定义好的 fahrenheit 变量赋值为对应的华氏温度的值。", + "您不需要顾虑 function 和 return 语句,它们会在之后的挑战中予以介绍。现在,您只需要使用您已学过的运算符。" ], "releasedOn": "January 1, 2016", "solutions": [ @@ -18,28 +18,28 @@ ], "tests": [ { - "text": "convertToF(0) should return a number", - "testString": "assert(typeof convertToF(0) === 'number', 'convertToF(0) should return a number');" + "text": "convertToF(0) 应该返回一个数字", + "testString": "assert(typeof convertToF(0) === 'number', 'convertToF(0) 应该返回一个数字');" }, { - "text": "convertToF(-30) should return a value of -22", - "testString": "assert(convertToF(-30) === -22, 'convertToF(-30) should return a value of -22');" + "text": "convertToF(-30) 应该返回 -22", + "testString": "assert(convertToF(-30) === -22, 'convertToF(-30) 应该返回 -22');" }, { - "text": "convertToF(-10) should return a value of 14", - "testString": "assert(convertToF(-10) === 14, 'convertToF(-10) should return a value of 14');" + "text": "convertToF(-10) 应该返回 14", + "testString": "assert(convertToF(-10) === 14, 'convertToF(-10) 应该返回 14');" }, { - "text": "convertToF(0) should return a value of 32", - "testString": "assert(convertToF(0) === 32, 'convertToF(0) should return a value of 32');" + "text": "convertToF(0) 应该返回 32", + "testString": "assert(convertToF(0) === 32, 'convertToF(0) 应该返回 32');" }, { - "text": "convertToF(20) should return a value of 68", - "testString": "assert(convertToF(20) === 68, 'convertToF(20) should return a value of 68');" + "text": "convertToF(20) 应该返回 68", + "testString": "assert(convertToF(20) === 68, 'convertToF(20) 应该返回 68');" }, { - "text": "convertToF(30) should return a value of 86", - "testString": "assert(convertToF(30) === 86, 'convertToF(30) should return a value of 86');" + "text": "convertToF(30) 应该返回 86", + "testString": "assert(convertToF(30) === 86, 'convertToF(30) 应该返回 86');" } ], "challengeType": 1, @@ -66,27 +66,27 @@ "id": "a202eed8fc186c8434cb6d61", "title": "Reverse a String", "description": [ - "Reverse the provided string.", - "You may need to turn the string into an array before you can reverse it.", - "Your result must be a string.", - "Remember to use Read-Search-Ask if you get stuck. Write your own code." + "反转给出的字符串。", + "您在反转字符串前可能需要将其切分成字符的数组。", + "您的结果必须是一个字符串。", + "如果您有任何疑问,可以访问 Read-Search-Ask 。请您独立解决挑战中的问题。" ], "tests": [ { - "text": "reverseString(\"hello\") should return a string.", - "testString": "assert(typeof reverseString(\"hello\") === \"string\", 'reverseString(\"hello\") should return a string.');" + "text": "reverseString(\"hello\") 应该返回一个字符串。", + "testString": "assert(typeof reverseString(\"hello\") === \"string\", 'reverseString(\"hello\") 应该返回一个字符串。');" }, { - "text": "reverseString(\"hello\") should become \"olleh\".", - "testString": "assert(reverseString(\"hello\") === \"olleh\", 'reverseString(\"hello\") should become \"olleh\".');" + "text": "reverseString(\"hello\") 应该返回 \"olleh\"", + "testString": "assert(reverseString(\"hello\") === \"olleh\", 'reverseString(\"hello\") 应该返回 \"olleh\"。');" }, { - "text": "reverseString(\"Howdy\") should become \"ydwoH\".", - "testString": "assert(reverseString(\"Howdy\") === \"ydwoH\", 'reverseString(\"Howdy\") should become \"ydwoH\".');" + "text": "reverseString(\"Howdy\") 应该返回 \"ydwoH\"", + "testString": "assert(reverseString(\"Howdy\") === \"ydwoH\", 'reverseString(\"Howdy\") 应该返回 \"ydwoH\"。');" }, { - "text": "reverseString(\"Greetings from Earth\") should return \"htraE morf sgniteerG\".", - "testString": "assert(reverseString(\"Greetings from Earth\") === \"htraE morf sgniteerG\", 'reverseString(\"Greetings from Earth\") should return \"htraE morf sgniteerG\".');" + "text": "reverseString(\"Greetings from Earth\") 应该返回 \"htraE morf sgniteerG\"。", + "testString": "assert(reverseString(\"Greetings from Earth\") === \"htraE morf sgniteerG\", 'reverseString(\"Greetings from Earth\") 应该返回 \"htraE morf sgniteerG\"。');" } ], "isRequired": true, @@ -121,33 +121,33 @@ "id": "a302f7aae1aa3152a5b413bc", "title": "Factorialize a Number", "description": [ - "Return the factorial of the provided integer.", - "If the integer is represented with the letter n, a factorial is the product of all positive integers less than or equal to n.", - "Factorials are often represented with the shorthand notation n!", - "For example: 5! = 1 * 2 * 3 * 4 * 5 = 120", - "Only integers greater than or equal to zero will be supplied to the function.", - "Remember to use Read-Search-Ask if you get stuck. Write your own code." + "返回一个给定整数的阶乘。", + "若 n 是一个整数,n 的阶乘就是所有小于等于 n 的正整数的乘积。", + "n 的阶乘通常用符号 n! 来表示。", + "例如: 5! = 1 * 2 * 3 * 4 * 5 = 120", + "只有非负整数会被作为函数的输入参数。", + "如果您有任何疑问,可以访问 Read-Search-Ask 。请您独立解决挑战中的问题。" ], "tests": [ { - "text": "factorialize(5) should return a number.", - "testString": "assert(typeof factorialize(5) === 'number', 'factorialize(5) should return a number.');" + "text": "factorialize(5) 应该返回一个数字。", + "testString": "assert(typeof factorialize(5) === 'number', 'factorialize(5) 应该返回一个数字。');" }, { - "text": "factorialize(5) should return 120.", - "testString": "assert(factorialize(5) === 120, 'factorialize(5) should return 120.');" + "text": "factorialize(5) 应该返回 120。", + "testString": "assert(factorialize(5) === 120, 'factorialize(5) 应该返回 120。');" }, { - "text": "factorialize(10) should return 3628800.", - "testString": "assert(factorialize(10) === 3628800, 'factorialize(10) should return 3628800.');" + "text": "factorialize(10) 应该返回 3628800。", + "testString": "assert(factorialize(10) === 3628800, 'factorialize(10) 应该返回 3628800。');" }, { - "text": "factorialize(20) should return 2432902008176640000.", - "testString": "assert(factorialize(20) === 2432902008176640000, 'factorialize(20) should return 2432902008176640000.');" + "text": "factorialize(20) 应该返回 2432902008176640000。", + "testString": "assert(factorialize(20) === 2432902008176640000, 'factorialize(20) 应该返回 2432902008176640000。');" }, { - "text": "factorialize(0) should return 1.", - "testString": "assert(factorialize(0) === 1, 'factorialize(0) should return 1.');" + "text": "factorialize(0) 应该返回 1。", + "testString": "assert(factorialize(0) === 1, 'factorialize(0) 应该返回 1。');" } ], "isRequired": true, @@ -179,34 +179,34 @@ "id": "a26cbbe9ad8655a977e1ceb5", "title": "Find the Longest Word in a String", "description": [ - "Return the length of the longest word in the provided sentence.", - "Your response should be a number.", - "Remember to use Read-Search-Ask if you get stuck. Write your own code." + "返回给出的句子中最长的单词的长度。", + "您的返回应该是一个数字。", + "如果您有任何疑问,可以访问 Read-Search-Ask 。请您独立解决挑战中的问题。" ], "tests": [ { - "text": "findLongestWordLength(\"The quick brown fox jumped over the lazy dog\") should return a number.", - "testString": "assert(typeof findLongestWordLength(\"The quick brown fox jumped over the lazy dog\") === \"number\", 'findLongestWordLength(\"The quick brown fox jumped over the lazy dog\") should return a number.');" + "text": "findLongestWordLength(\"The quick brown fox jumped over the lazy dog\") 应该返回一个数字。", + "testString": "assert(typeof findLongestWordLength(\"The quick brown fox jumped over the lazy dog\") === \"number\", 'findLongestWordLength(\"The quick brown fox jumped over the lazy dog\") 应该返回一个数字。');" }, { - "text": "findLongestWordLength(\"The quick brown fox jumped over the lazy dog\") should return 6.", - "testString": "assert(findLongestWordLength(\"The quick brown fox jumped over the lazy dog\") === 6, 'findLongestWordLength(\"The quick brown fox jumped over the lazy dog\") should return 6.');" + "text": "findLongestWordLength(\"The quick brown fox jumped over the lazy dog\") 应该返回 6。", + "testString": "assert(findLongestWordLength(\"The quick brown fox jumped over the lazy dog\") === 6, 'findLongestWordLength(\"The quick brown fox jumped over the lazy dog\") 应该返回 6。');" }, { - "text": "findLongestWordLength(\"May the force be with you\") should return 5.", - "testString": "assert(findLongestWordLength(\"May the force be with you\") === 5, 'findLongestWordLength(\"May the force be with you\") should return 5.');" + "text": "findLongestWordLength(\"May the force be with you\") 应该返回 5。", + "testString": "assert(findLongestWordLength(\"May the force be with you\") === 5, 'findLongestWordLength(\"May the force be with you\") 应该返回 5。');" }, { - "text": "findLongestWordLength(\"Google do a barrel roll\") should return 6.", - "testString": "assert(findLongestWordLength(\"Google do a barrel roll\") === 6, 'findLongestWordLength(\"Google do a barrel roll\") should return 6.');" + "text": "findLongestWordLength(\"Google do a barrel roll\") 应该返回 6。", + "testString": "assert(findLongestWordLength(\"Google do a barrel roll\") === 6, 'findLongestWordLength(\"Google do a barrel roll\") 应该返回 6。');" }, { - "text": "findLongestWordLength(\"What is the average airspeed velocity of an unladen swallow\") should return 8.", - "testString": "assert(findLongestWordLength(\"What is the average airspeed velocity of an unladen swallow\") === 8, 'findLongestWordLength(\"What is the average airspeed velocity of an unladen swallow\") should return 8.');" + "text": "findLongestWordLength(\"What is the average airspeed velocity of an unladen swallow\") 应该返回 8。", + "testString": "assert(findLongestWordLength(\"What is the average airspeed velocity of an unladen swallow\") === 8, 'findLongestWordLength(\"What is the average airspeed velocity of an unladen swallow\") 应该返回 8。');" }, { - "text": "findLongestWordLength(\"What if we try a super-long word such as otorhinolaryngology\") should return 19.", - "testString": "assert(findLongestWordLength(\"What if we try a super-long word such as otorhinolaryngology\") === 19, 'findLongestWordLength(\"What if we try a super-long word such as otorhinolaryngology\") should return 19.');" + "text": "findLongestWordLength(\"What if we try a super-long word such as otorhinolaryngology\") 应该返回 19。", + "testString": "assert(findLongestWordLength(\"What if we try a super-long word such as otorhinolaryngology\") === 19, 'findLongestWordLength(\"What if we try a super-long word such as otorhinolaryngology\") 应该返回 19。');" } ], "isRequired": true, @@ -239,26 +239,26 @@ "id": "a789b3483989747d63b0e427", "title": "Return Largest Numbers in Arrays", "description": [ - "Return an array consisting of the largest number from each provided sub-array. For simplicity, the provided array will contain exactly 4 sub-arrays.", - "Remember, you can iterate through an array with a simple for loop, and access each member with array syntax arr[i].", - "Remember to use Read-Search-Ask if you get stuck. Write your own code." + "返回一个数组,它要由给出的所有子数组中的最大值组成。简单起见,给出的数组总会包含4个子数组。", + "记得您可以在一个简单的 for 循环中遍历一个数组,并用 arr[i] 这样的语法来访问数组中的元素。", + "如果您有任何疑问,可以访问 Read-Search-Ask 。请您独立解决挑战中的问题。" ], "tests": [ { - "text": "largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]) should return an array.", - "testString": "assert(largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]).constructor === Array, 'largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]) should return an array.');" + "text": "largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]) 应该返回一个数组。", + "testString": "assert(largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]).constructor === Array, 'largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]) 应该返回一个数组。');" }, { - "text": "largestOfFour([[13, 27, 18, 26], [4, 5, 1, 3], [32, 35, 37, 39], [1000, 1001, 857, 1]]) should return [27, 5, 39, 1001].", - "testString": "assert.deepEqual(largestOfFour([[13, 27, 18, 26], [4, 5, 1, 3], [32, 35, 37, 39], [1000, 1001, 857, 1]]), [27, 5, 39, 1001], 'largestOfFour([[13, 27, 18, 26], [4, 5, 1, 3], [32, 35, 37, 39], [1000, 1001, 857, 1]]) should return [27, 5, 39, 1001].');" + "text": "largestOfFour([[13, 27, 18, 26], [4, 5, 1, 3], [32, 35, 37, 39], [1000, 1001, 857, 1]]) 应该返回 [27, 5, 39, 1001]。", + "testString": "assert.deepEqual(largestOfFour([[13, 27, 18, 26], [4, 5, 1, 3], [32, 35, 37, 39], [1000, 1001, 857, 1]]), [27, 5, 39, 1001], 'largestOfFour([[13, 27, 18, 26], [4, 5, 1, 3], [32, 35, 37, 39], [1000, 1001, 857, 1]]) 应该返回 [27, 5, 39, 1001]。');" }, { - "text": "largestOfFour([[4, 9, 1, 3], [13, 35, 18, 26], [32, 35, 97, 39], [1000000, 1001, 857, 1]]) should return [9, 35, 97, 1000000].", - "testString": "assert.deepEqual(largestOfFour([[4, 9, 1, 3], [13, 35, 18, 26], [32, 35, 97, 39], [1000000, 1001, 857, 1]]), [9, 35, 97, 1000000], 'largestOfFour([[4, 9, 1, 3], [13, 35, 18, 26], [32, 35, 97, 39], [1000000, 1001, 857, 1]]) should return [9, 35, 97, 1000000].');" + "text": "largestOfFour([[4, 9, 1, 3], [13, 35, 18, 26], [32, 35, 97, 39], [1000000, 1001, 857, 1]]) 应该返回 [9, 35, 97, 1000000]。", + "testString": "assert.deepEqual(largestOfFour([[4, 9, 1, 3], [13, 35, 18, 26], [32, 35, 97, 39], [1000000, 1001, 857, 1]]), [9, 35, 97, 1000000], 'largestOfFour([[4, 9, 1, 3], [13, 35, 18, 26], [32, 35, 97, 39], [1000000, 1001, 857, 1]]) 应该返回 [9, 35, 97, 1000000]。');" }, { - "text": "largestOfFour([[17, 23, 25, 12], [25, 7, 34, 48], [4, -10, 18, 21], [-72, -3, -17, -10]]) should return [25, 48, 21, -3].", - "testString": "assert.deepEqual(largestOfFour([[17, 23, 25, 12], [25, 7, 34, 48], [4, -10, 18, 21], [-72, -3, -17, -10]]), [25, 48, 21, -3], 'largestOfFour([[17, 23, 25, 12], [25, 7, 34, 48], [4, -10, 18, 21], [-72, -3, -17, -10]]) should return [25, 48, 21, -3].');" + "text": "largestOfFour([[17, 23, 25, 12], [25, 7, 34, 48], [4, -10, 18, 21], [-72, -3, -17, -10]]) 应该返回 [25, 48, 21, -3]。", + "testString": "assert.deepEqual(largestOfFour([[17, 23, 25, 12], [25, 7, 34, 48], [4, -10, 18, 21], [-72, -3, -17, -10]]), [25, 48, 21, -3], 'largestOfFour([[17, 23, 25, 12], [25, 7, 34, 48], [4, -10, 18, 21], [-72, -3, -17, -10]]) 应该返回 [25, 48, 21, -3]。');" } ], "isRequired": true, @@ -291,54 +291,54 @@ "id": "acda2fb1324d9b0fa741e6b5", "title": "Confirm the Ending", "description": [ - "Check if a string (first argument, str) ends with the given target string (second argument, target).", - "This challenge can be solved with the .endsWith() method, which was introduced in ES2015. But for the purpose of this challenge, we would like you to use one of the JavaScript substring methods instead.", - "Remember to use Read-Search-Ask if you get stuck. Write your own code." + "检查一个字符串(第一个参数, str )是否以给定的字符串(第二个参数 target )结束。", + "本题目可以用 ES2015 引入的 .endsWith() 方法来解决。但本挑战的目的是让您使用 JavaScript 的一个 substring 方法。", + "如果您有任何疑问,可以访问 Read-Search-Ask 。请您独立解决挑战中的问题。" ], "tests": [ { - "text": "confirmEnding(\"Bastian\", \"n\") should return true.", - "testString": "assert(confirmEnding(\"Bastian\", \"n\") === true, 'confirmEnding(\"Bastian\", \"n\") should return true.');" + "text": "confirmEnding(\"Bastian\", \"n\") 应该返回 true。", + "testString": "assert(confirmEnding(\"Bastian\", \"n\") === true, 'confirmEnding(\"Bastian\", \"n\") 应该返回 true。');" }, { - "text": "confirmEnding(\"Congratulation\", \"on\") should return true.", - "testString": "assert(confirmEnding(\"Congratulation\", \"on\") === true, 'confirmEnding(\"Congratulation\", \"on\") should return true.');" + "text": "confirmEnding(\"Congratulation\", \"on\") 应该返回 true。", + "testString": "assert(confirmEnding(\"Congratulation\", \"on\") === true, 'confirmEnding(\"Congratulation\", \"on\") 应该返回 true。');" }, { - "text": "confirmEnding(\"Connor\", \"n\") should return false.", - "testString": "assert(confirmEnding(\"Connor\", \"n\") === false, 'confirmEnding(\"Connor\", \"n\") should return false.');" + "text": "confirmEnding(\"Connor\", \"n\") 应该返回 false。", + "testString": "assert(confirmEnding(\"Connor\", \"n\") === false, 'confirmEnding(\"Connor\", \"n\") 应该返回 false。');" }, { - "text": "confirmEnding(\"Walking on water and developing software from a specification are easy if both are frozen\", \"specification\") should return false.", - "testString": "assert(confirmEnding(\"Walking on water and developing software from a specification are easy if both are frozen\", \"specification\") === false, 'confirmEnding(\"Walking on water and developing software from a specification are easy if both are frozen\", \"specification\") should return false.');" + "text": "confirmEnding(\"Walking on water and developing software from a specification are easy if both are frozen\", \"specification\") 应该返回 false。", + "testString": "assert(confirmEnding(\"Walking on water and developing software from a specification are easy if both are frozen\", \"specification\") === false, 'confirmEnding(\"Walking on water and developing software from a specification are easy if both are frozen\", \"specification\") 应该返回 false。');" }, { - "text": "confirmEnding(\"He has to give me a new name\", \"name\") should return true.", - "testString": "assert(confirmEnding(\"He has to give me a new name\", \"name\") === true, 'confirmEnding(\"He has to give me a new name\", \"name\") should return true.');" + "text": "confirmEnding(\"He has to give me a new name\", \"name\") 应该返回 true。", + "testString": "assert(confirmEnding(\"He has to give me a new name\", \"name\") === true, 'confirmEnding(\"He has to give me a new name\", \"name\") 应该返回 true。');" }, { - "text": "confirmEnding(\"Open sesame\", \"same\") should return true.", - "testString": "assert(confirmEnding(\"Open sesame\", \"same\") === true, 'confirmEnding(\"Open sesame\", \"same\") should return true.');" + "text": "confirmEnding(\"Open sesame\", \"same\") 应该返回 true。", + "testString": "assert(confirmEnding(\"Open sesame\", \"same\") === true, 'confirmEnding(\"Open sesame\", \"same\") 应该返回 true。');" }, { - "text": "confirmEnding(\"Open sesame\", \"pen\") should return false.", - "testString": "assert(confirmEnding(\"Open sesame\", \"pen\") === false, 'confirmEnding(\"Open sesame\", \"pen\") should return false.');" + "text": "confirmEnding(\"Open sesame\", \"pen\") 应该返回 false。", + "testString": "assert(confirmEnding(\"Open sesame\", \"pen\") === false, 'confirmEnding(\"Open sesame\", \"pen\") 应该返回 false。');" }, { - "text": "confirmEnding(\"Open sesame\", \"game\") should return false.", - "testString": "assert(confirmEnding(\"Open sesame\", \"game\") === false, 'confirmEnding(\"Open sesame\", \"game\") should return false.');" + "text": "confirmEnding(\"Open sesame\", \"game\") 应该返回 false。", + "testString": "assert(confirmEnding(\"Open sesame\", \"game\") === false, 'confirmEnding(\"Open sesame\", \"game\") 应该返回 false。');" }, { - "text": "confirmEnding(\"If you want to save our world, you must hurry. We dont know how much longer we can withstand the nothing\", \"mountain\") should return false.", - "testString": "assert(confirmEnding(\"If you want to save our world, you must hurry. We dont know how much longer we can withstand the nothing\", \"mountain\") === false, 'confirmEnding(\"If you want to save our world, you must hurry. We dont know how much longer we can withstand the nothing\", \"mountain\") should return false.');" + "text": "confirmEnding(\"If you want to save our world, you must hurry. We dont know how much longer we can withstand the nothing\", \"mountain\") 应该返回 false。", + "testString": "assert(confirmEnding(\"If you want to save our world, you must hurry. We dont know how much longer we can withstand the nothing\", \"mountain\") === false, 'confirmEnding(\"If you want to save our world, you must hurry. We dont know how much longer we can withstand the nothing\", \"mountain\") 应该返回 false。');" }, { - "text": "confirmEnding(\"Abstraction\", \"action\") should return true.", - "testString": "assert(confirmEnding(\"Abstraction\", \"action\") === true, 'confirmEnding(\"Abstraction\", \"action\") should return true.');" + "text": "confirmEnding(\"Abstraction\", \"action\") 应该返回 true。", + "testString": "assert(confirmEnding(\"Abstraction\", \"action\") === true, 'confirmEnding(\"Abstraction\", \"action\") 应该返回 true。');" }, { - "text": "Do not use the built-in method .endsWith() to solve the challenge.", - "testString": "assert(!(/\\.endsWith\\(.*?\\)\\s*?;?/.test(code)) && !(/\\['endsWith'\\]/.test(code)), 'Do not use the built-in method .endsWith() to solve the challenge.');" + "text": "请不要用内置的 .endsWith() 方法来解决本挑战。", + "testString": "assert(!(/\\.endsWith\\(.*?\\)\\s*?;?/.test(code)) && !(/\\['endsWith'\\]/.test(code)), '请不要用内置的 .endsWith() 方法来解决本挑战。');" } ], "isRequired": true, @@ -373,37 +373,37 @@ "id": "afcc8d540bea9ea2669306b6", "title": "Repeat a String Repeat a String", "description": [ - "Repeat a given string str (first argument) for num times (second argument). Return an empty string if num is not a positive number.", - "Remember to use Read-Search-Ask if you get stuck. Write your own code." + "将一个给定的字符串(第一个参数, str )重复 num (第二个参数)次。如果 num 不是一个正数,返回一个空字符串。", + "如果您有任何疑问,可以访问 Read-Search-Ask 。请您独立解决挑战中的问题。" ], "tests": [ { - "text": "repeatStringNumTimes(\"*\", 3) should return \"***\".", - "testString": "assert(repeatStringNumTimes(\"*\", 3) === \"***\", 'repeatStringNumTimes(\"*\", 3) should return \"***\".');" + "text": "repeatStringNumTimes(\"*\", 3) 应该返回 \"***\"。", + "testString": "assert(repeatStringNumTimes(\"*\", 3) === \"***\", 'repeatStringNumTimes(\"*\", 3) 应该返回 \"***\"。');" }, { - "text": "repeatStringNumTimes(\"abc\", 3) should return \"abcabcabc\".", - "testString": "assert(repeatStringNumTimes(\"abc\", 3) === \"abcabcabc\", 'repeatStringNumTimes(\"abc\", 3) should return \"abcabcabc\".');" + "text": "repeatStringNumTimes(\"abc\", 3) 应该返回 \"abcabcabc\"。", + "testString": "assert(repeatStringNumTimes(\"abc\", 3) === \"abcabcabc\", 'repeatStringNumTimes(\"abc\", 3) 应该返回 \"abcabcabc\"。');" }, { - "text": "repeatStringNumTimes(\"abc\", 4) should return \"abcabcabcabc\".", - "testString": "assert(repeatStringNumTimes(\"abc\", 4) === \"abcabcabcabc\", 'repeatStringNumTimes(\"abc\", 4) should return \"abcabcabcabc\".');" + "text": "repeatStringNumTimes(\"abc\", 4) 应该返回 \"abcabcabcabc\"。", + "testString": "assert(repeatStringNumTimes(\"abc\", 4) === \"abcabcabcabc\", 'repeatStringNumTimes(\"abc\", 4) 应该返回 \"abcabcabcabc\"。');" }, { - "text": "repeatStringNumTimes(\"abc\", 1) should return \"abc\".", - "testString": "assert(repeatStringNumTimes(\"abc\", 1) === \"abc\", 'repeatStringNumTimes(\"abc\", 1) should return \"abc\".');" + "text": "repeatStringNumTimes(\"abc\", 1) 应该返回 \"abc\"。", + "testString": "assert(repeatStringNumTimes(\"abc\", 1) === \"abc\", 'repeatStringNumTimes(\"abc\", 1) 应该返回 \"abc\"。');" }, { - "text": "repeatStringNumTimes(\"*\", 8) should return \"********\".", - "testString": "assert(repeatStringNumTimes(\"*\", 8) === \"********\", 'repeatStringNumTimes(\"*\", 8) should return \"********\".');" + "text": "repeatStringNumTimes(\"*\", 8) 应该返回 \"********\"。", + "testString": "assert(repeatStringNumTimes(\"*\", 8) === \"********\", 'repeatStringNumTimes(\"*\", 8) 应该返回 \"********\"。');" }, { - "text": "repeatStringNumTimes(\"abc\", -2) should return \"\".", - "testString": "assert(repeatStringNumTimes(\"abc\", -2) === \"\", 'repeatStringNumTimes(\"abc\", -2) should return \"\".');" + "text": "repeatStringNumTimes(\"abc\", -2) 应该返回 \"\"。", + "testString": "assert(repeatStringNumTimes(\"abc\", -2) === \"\", 'repeatStringNumTimes(\"abc\", -2) 应该返回 \"\"。');" }, { - "text": "The built-in repeat()-method should not be used", - "testString": "assert(!/\\.repeat/g.test(code), 'The built-in repeat()-method should not be used');" + "text": "请不要使用内置的 repeat() 方法。", + "testString": "assert(!/\\.repeat/g.test(code), '请不要使用内置的 repeat() 方法。');" } ], "isRequired": true, @@ -436,33 +436,33 @@ "id": "ac6993d51946422351508a41", "title": "Truncate a String", "description": [ - "Truncate a string (first argument) if it is longer than the given maximum string length (second argument). Return the truncated string with a ... ending.", - "Remember to use Read-Search-Ask if you get stuck. Write your own code." + "如果一个字符串(第一个参数)的长度大于给出的值(第二个参数),则截断它并在其后加上 ... 。返回被截断的字符串。", + "如果您有任何疑问,可以访问 Read-Search-Ask 。请您独立解决挑战中的问题。" ], "tests": [ { - "text": "truncateString(\"A-tisket a-tasket A green and yellow basket\", 8) should return \"A-tisket...\".", - "testString": "assert(truncateString(\"A-tisket a-tasket A green and yellow basket\", 8) === \"A-tisket...\", 'truncateString(\"A-tisket a-tasket A green and yellow basket\", 8) should return \"A-tisket...\".');" + "text": "truncateString(\"A-tisket a-tasket A green and yellow basket\", 8) 应该返回 \"A-tisket...\"。", + "testString": "assert(truncateString(\"A-tisket a-tasket A green and yellow basket\", 8) === \"A-tisket...\", 'truncateString(\"A-tisket a-tasket A green and yellow basket\", 8) 应该返回 \"A-tisket...\"。');" }, { - "text": "truncateString(\"Peter Piper picked a peck of pickled peppers\", 11) should return \"Peter Piper...\".", - "testString": "assert(truncateString(\"Peter Piper picked a peck of pickled peppers\", 11) === \"Peter Piper...\", 'truncateString(\"Peter Piper picked a peck of pickled peppers\", 11) should return \"Peter Piper...\".');" + "text": "truncateString(\"Peter Piper picked a peck of pickled peppers\", 11) 应该返回 \"Peter Piper...\"。", + "testString": "assert(truncateString(\"Peter Piper picked a peck of pickled peppers\", 11) === \"Peter Piper...\", 'truncateString(\"Peter Piper picked a peck of pickled peppers\", 11) 应该返回 \"Peter Piper...\"。');" }, { - "text": "truncateString(\"A-tisket a-tasket A green and yellow basket\", \"A-tisket a-tasket A green and yellow basket\".length) should return \"A-tisket a-tasket A green and yellow basket\".", - "testString": "assert(truncateString(\"A-tisket a-tasket A green and yellow basket\", \"A-tisket a-tasket A green and yellow basket\".length) === \"A-tisket a-tasket A green and yellow basket\", 'truncateString(\"A-tisket a-tasket A green and yellow basket\", \"A-tisket a-tasket A green and yellow basket\".length) should return \"A-tisket a-tasket A green and yellow basket\".');" + "text": "truncateString(\"A-tisket a-tasket A green and yellow basket\", \"A-tisket a-tasket A green and yellow basket\".length) 应该返回 \"A-tisket a-tasket A green and yellow basket\"。", + "testString": "assert(truncateString(\"A-tisket a-tasket A green and yellow basket\", \"A-tisket a-tasket A green and yellow basket\".length) === \"A-tisket a-tasket A green and yellow basket\", 'truncateString(\"A-tisket a-tasket A green and yellow basket\", \"A-tisket a-tasket A green and yellow basket\".length) 应该返回 \"A-tisket a-tasket A green and yellow basket\"。');" }, { - "text": "truncateString(\"A-tisket a-tasket A green and yellow basket\", \"A-tisket a-tasket A green and yellow basket\".length + 2) should return \"A-tisket a-tasket A green and yellow basket\".", - "testString": "assert(truncateString('A-tisket a-tasket A green and yellow basket', 'A-tisket a-tasket A green and yellow basket'.length + 2) === 'A-tisket a-tasket A green and yellow basket', 'truncateString(\"A-tisket a-tasket A green and yellow basket\", \"A-tisket a-tasket A green and yellow basket\".length + 2) should return \"A-tisket a-tasket A green and yellow basket\".');" + "text": "truncateString(\"A-tisket a-tasket A green and yellow basket\", \"A-tisket a-tasket A green and yellow basket\".length + 2) 应该返回 \"A-tisket a-tasket A green and yellow basket\"。", + "testString": "assert(truncateString('A-tisket a-tasket A green and yellow basket', 'A-tisket a-tasket A green and yellow basket'.length + 2) === 'A-tisket a-tasket A green and yellow basket', 'truncateString(\"A-tisket a-tasket A green and yellow basket\", \"A-tisket a-tasket A green and yellow basket\".length + 2) 应该返回 \"A-tisket a-tasket A green and yellow basket\"。');" }, { - "text": "truncateString(\"A-\", 1) should return \"A...\".", - "testString": "assert(truncateString(\"A-\", 1) === \"A...\", 'truncateString(\"A-\", 1) should return \"A...\".');" + "text": "truncateString(\"A-\", 1) 应该返回 \"A...\"。", + "testString": "assert(truncateString(\"A-\", 1) === \"A...\", 'truncateString(\"A-\", 1) 应该返回 \"A...\"。');" }, { - "text": "truncateString(\"Absolutely Longer\", 2) should return \"Ab...\".", - "testString": "assert(truncateString(\"Absolutely Longer\", 2) === \"Ab...\", 'truncateString(\"Absolutely Longer\", 2) should return \"Ab...\".');" + "text": "truncateString(\"Absolutely Longer\", 2) 应该返回 \"Ab...\"。", + "testString": "assert(truncateString(\"Absolutely Longer\", 2) === \"Ab...\", 'truncateString(\"Absolutely Longer\", 2) 应该返回 \"Ab...\"。');" } ], "isRequired": true, @@ -495,20 +495,20 @@ "id": "a6e40f1041b06c996f7b2406", "title": "Finders Keepers", "description": [ - "Create a function that looks through an array (first argument) and returns the first element in the array that passes a truth test (second argument). If no element passes the test, return undefined.", - "Remember to use Read-Search-Ask if you get stuck. Try to pair program. Write your own code." + "请写一个函数来检查一个数组(第一个参数)中的元素,并返回数组中第一个通过校验测试(第二个参数,一个接受一个参数并返回一个布尔值的函数)的元素。如果没有元素通过测试,则返回 undefined。", + "如果您有任何疑问,可以访问 Read-Search-Ask 。您可以与他人结对编程。请您独立解决挑战中的问题。" ], "solutions": [ "function findElement(arr, func) {\n let num;\n\n arr.some(e => {\n if (func(e)) {\n num = e;\n return true;\n }\n });\n\n return num;\n}\n\nfindElement([1, 2, 3, 4], num => num % 2 === 0);\n" ], "tests": [ { - "text": "findElement([1, 3, 5, 8, 9, 10], function(num) { return num % 2 === 0; }) should return 8.", - "testString": "assert.strictEqual(findElement([1, 3, 5, 8, 9, 10], function(num) { return num % 2 === 0; }), 8, 'findElement([1, 3, 5, 8, 9, 10], function(num) { return num % 2 === 0; }) should return 8.');" + "text": "findElement([1, 3, 5, 8, 9, 10], function(num) { return num % 2 === 0; }) 应该返回 8。", + "testString": "assert.strictEqual(findElement([1, 3, 5, 8, 9, 10], function(num) { return num % 2 === 0; }), 8, 'findElement([1, 3, 5, 8, 9, 10], function(num) { return num % 2 === 0; }) 应该返回 8。');" }, { - "text": "findElement([1, 3, 5, 9], function(num) { return num % 2 === 0; }) should return undefined.", - "testString": "assert.strictEqual(findElement([1, 3, 5, 9], function(num) { return num % 2 === 0; }), undefined, 'findElement([1, 3, 5, 9], function(num) { return num % 2 === 0; }) should return undefined.');" + "text": "findElement([1, 3, 5, 9], function(num) { return num % 2 === 0; }) 应该返回 undefined。", + "testString": "assert.strictEqual(findElement([1, 3, 5, 9], function(num) { return num % 2 === 0; }), undefined, 'findElement([1, 3, 5, 9], function(num) { return num % 2 === 0; }) 应该返回 undefined。');" } ], "MDNlinks": [ @@ -538,53 +538,53 @@ "id": "a77dbc43c33f39daa4429b4f", "title": "Boo who", "description": [ - "Check if a value is classified as a boolean primitive. Return true or false.", - "Boolean primitives are true and false.", - "Remember to use Read-Search-Ask if you get stuck. Try to pair program. Write your own code." + "检查一个值是否是原始的布尔值(boolean)类型。返回 true 或者 false。", + "布尔值原始类型为 true 或者 false。", + "如果您有任何疑问,可以访问 Read-Search-Ask 。您可以与他人结对编程。请您独立解决挑战中的问题。" ], "solutions": [ "function booWho(bool) {\n return typeof bool === \"boolean\";\n}\n\nbooWho(null);" ], "tests": [ { - "text": "booWho(true) should return true.", - "testString": "assert.strictEqual(booWho(true), true, 'booWho(true) should return true.');" + "text": "booWho(true) 应该返回 true。", + "testString": "assert.strictEqual(booWho(true), true, 'booWho(true) 应该返回 true。');" }, { - "text": "booWho(false) should return true.", - "testString": "assert.strictEqual(booWho(false), true, 'booWho(false) should return true.');" + "text": "booWho(false) 应该返回 true。", + "testString": "assert.strictEqual(booWho(false), true, 'booWho(false) 应该返回 true。');" }, { - "text": "booWho([1, 2, 3]) should return false.", - "testString": "assert.strictEqual(booWho([1, 2, 3]), false, 'booWho([1, 2, 3]) should return false.');" + "text": "booWho([1, 2, 3]) 应该返回 false。", + "testString": "assert.strictEqual(booWho([1, 2, 3]), false, 'booWho([1, 2, 3]) 应该返回 false。');" }, { - "text": "booWho([].slice) should return false.", - "testString": "assert.strictEqual(booWho([].slice), false, 'booWho([].slice) should return false.');" + "text": "booWho([].slice) 应该返回 false。", + "testString": "assert.strictEqual(booWho([].slice), false, 'booWho([].slice) 应该返回 false。');" }, { - "text": "booWho({ \"a\": 1 }) should return false.", - "testString": "assert.strictEqual(booWho({ \"a\": 1 }), false, 'booWho({ \"a\": 1 }) should return false.');" + "text": "booWho({ \"a\": 1 }) 应该返回 false。", + "testString": "assert.strictEqual(booWho({ \"a\": 1 }), false, 'booWho({ \"a\": 1 }) 应该返回 false。');" }, { - "text": "booWho(1) should return false.", - "testString": "assert.strictEqual(booWho(1), false, 'booWho(1) should return false.');" + "text": "booWho(1) 应该返回 false。", + "testString": "assert.strictEqual(booWho(1), false, 'booWho(1) 应该返回 false。');" }, { - "text": "booWho(NaN) should return false.", - "testString": "assert.strictEqual(booWho(NaN), false, 'booWho(NaN) should return false.');" + "text": "booWho(NaN) 应该返回 false。", + "testString": "assert.strictEqual(booWho(NaN), false, 'booWho(NaN) 应该返回 false。');" }, { - "text": "booWho(\"a\") should return false.", - "testString": "assert.strictEqual(booWho(\"a\"), false, 'booWho(\"a\") should return false.');" + "text": "booWho(\"a\") 应该返回 false。", + "testString": "assert.strictEqual(booWho(\"a\"), false, 'booWho(\"a\") 应该返回 false。');" }, { - "text": "booWho(\"true\") should return false.", - "testString": "assert.strictEqual(booWho(\"true\"), false, 'booWho(\"true\") should return false.');" + "text": "booWho(\"true\") 应该返回 false。", + "testString": "assert.strictEqual(booWho(\"true\"), false, 'booWho(\"true\") 应该返回 false。');" }, { - "text": "booWho(\"false\") should return false.", - "testString": "assert.strictEqual(booWho(\"false\"), false, 'booWho(\"false\") should return false.');" + "text": "booWho(\"false\") 应该返回 false。", + "testString": "assert.strictEqual(booWho(\"false\"), false, 'booWho(\"false\") 应该返回 false。');" } ], "MDNlinks": [ @@ -614,26 +614,26 @@ "id": "ab6137d4e35944e21037b769", "title": "Title Case a Sentence", "description": [ - "Return the provided string with the first letter of each word capitalized. Make sure the rest of the word is in lower case.", - "For the purpose of this exercise, you should also capitalize connecting words like \"the\" and \"of\".", - "Remember to use Read-Search-Ask if you get stuck. Write your own code." + "将给出的字符串中所有单词的第一个字母变成大写,并返回得到的字符串。请确保其余的字母是小写的。", + "出于练习的目的,“ the ”“ of ”等虚词的首字母也要大写。", + "如果您有任何疑问,可以访问 Read-Search-Ask 。请您独立解决挑战中的问题。" ], "tests": [ { - "text": "titleCase(\"I'm a little tea pot\") should return a string.", - "testString": "assert(typeof titleCase(\"I'm a little tea pot\") === \"string\", 'titleCase(\"I'm a little tea pot\") should return a string.');" + "text": "titleCase(\"I'm a little tea pot\") 应该返回一个字符串。", + "testString": "assert(typeof titleCase(\"I'm a little tea pot\") === \"string\", 'titleCase(\"I'm a little tea pot\") 应该返回一个字符串。');" }, { - "text": "titleCase(\"I'm a little tea pot\") should return I'm A Little Tea Pot.", - "testString": "assert(titleCase(\"I'm a little tea pot\") === \"I'm A Little Tea Pot\", 'titleCase(\"I'm a little tea pot\") should return I'm A Little Tea Pot.');" + "text": "titleCase(\"I'm a little tea pot\") 应该返回 I'm A Little Tea Pot。", + "testString": "assert(titleCase(\"I'm a little tea pot\") === \"I'm A Little Tea Pot\", 'titleCase(\"I'm a little tea pot\") 应该返回 I'm A Little Tea Pot。');" }, { - "text": "titleCase(\"sHoRt AnD sToUt\") should return Short And Stout.", - "testString": "assert(titleCase(\"sHoRt AnD sToUt\") === \"Short And Stout\", 'titleCase(\"sHoRt AnD sToUt\") should return Short And Stout.');" + "text": "titleCase(\"sHoRt AnD sToUt\") 应该返回 Short And Stout。", + "testString": "assert(titleCase(\"sHoRt AnD sToUt\") === \"Short And Stout\", 'titleCase(\"sHoRt AnD sToUt\") 应该返回 Short And Stout。');" }, { - "text": "titleCase(\"HERE IS MY HANDLE HERE IS MY SPOUT\") should return Here Is My Handle Here Is My Spout.", - "testString": "assert(titleCase(\"HERE IS MY HANDLE HERE IS MY SPOUT\") === \"Here Is My Handle Here Is My Spout\", 'titleCase(\"HERE IS MY HANDLE HERE IS MY SPOUT\") should return Here Is My Handle Here Is My Spout.');" + "text": "titleCase(\"HERE IS MY HANDLE HERE IS MY SPOUT\") 应该返回 Here Is My Handle Here Is My Spout.", + "testString": "assert(titleCase(\"HERE IS MY HANDLE HERE IS MY SPOUT\") === \"Here Is My Handle Here Is My Spout\", 'titleCase(\"HERE IS MY HANDLE HERE IS MY SPOUT\") 应该返回 Here Is My Handle Here Is My Spout.');" } ], "isRequired": true, @@ -665,36 +665,36 @@ "id": "579e2a2c335b9d72dd32e05c", "title": "Slice and Splice", "description": [ - "You are given two arrays and an index.", - "Use the array methods slice and splice to copy each element of the first array into the second array, in order.", - "Begin inserting elements at index n of the second array.", - "Return the resulting array. The input arrays should remain the same after the function runs.", - "Remember to use Read-Search-Ask if you get stuck. Write your own code." + "本挑战的输入参数为:两个数组和一个索引值。", + "请利用数组的 slicesplice 方法,将第一个数组中的所有元素依次复制到第二个数组中。", + "请从第二个数组中索引值为 n 的地方开始插入。", + "返回插入元素后的数组。输入的两个数组在函数执行前后要保持不变。", + "如果您有任何疑问,可以访问 Read-Search-Ask 。请您独立解决挑战中的问题。" ], "tests": [ { - "text": "frankenSplice([1, 2, 3], [4, 5], 1) should return [4, 1, 2, 3, 5].", - "testString": "assert.deepEqual(frankenSplice([1, 2, 3], [4, 5], 1), [4, 1, 2, 3, 5], 'frankenSplice([1, 2, 3], [4, 5], 1) should return [4, 1, 2, 3, 5].');" + 。"text": "frankenSplice([1, 2, 3], [4, 5], 1) 应该返回 [4, 1, 2, 3, 5]。", + "testString": "assert.deepEqual(frankenSplice([1, 2, 3], [4, 5], 1), [4, 1, 2, 3, 5], 'frankenSplice([1, 2, 3], [4, 5], 1) 应该返回 [4, 1, 2, 3, 5]。');" }, { - "text": "frankenSplice([1, 2], [\"a\", \"b\"], 1) should return [\"a\", 1, 2, \"b\"].", - "testString": "assert.deepEqual(frankenSplice(testArr1, testArr2, 1), [\"a\", 1, 2, \"b\"], 'frankenSplice([1, 2], [\"a\", \"b\"], 1) should return [\"a\", 1, 2, \"b\"].');" + "text": "frankenSplice([1, 2], [\"a\", \"b\"], 1) 应该返回 [\"a\", 1, 2, \"b\"]。", + "testString": "assert.deepEqual(frankenSplice(testArr1, testArr2, 1), [\"a\", 1, 2, \"b\"], 'frankenSplice([1, 2], [\"a\", \"b\"], 1) 应该返回 [\"a\", 1, 2, \"b\"]。');" }, { - "text": "frankenSplice([\"claw\", \"tentacle\"], [\"head\", \"shoulders\", \"knees\", \"toes\"], 2) should return [\"head\", \"shoulders\", \"claw\", \"tentacle\", \"knees\", \"toes\"].", - "testString": "assert.deepEqual(frankenSplice([\"claw\", \"tentacle\"], [\"head\", \"shoulders\", \"knees\", \"toes\"], 2), [\"head\", \"shoulders\", \"claw\", \"tentacle\", \"knees\", \"toes\"], 'frankenSplice([\"claw\", \"tentacle\"], [\"head\", \"shoulders\", \"knees\", \"toes\"], 2) should return [\"head\", \"shoulders\", \"claw\", \"tentacle\", \"knees\", \"toes\"].');" + "text": "frankenSplice([\"claw\", \"tentacle\"], [\"head\", \"shoulders\", \"knees\", \"toes\"], 2) 应该返回 [\"head\", \"shoulders\", \"claw\", \"tentacle\", \"knees\", \"toes\"]。", + "testString": "assert.deepEqual(frankenSplice([\"claw\", \"tentacle\"], [\"head\", \"shoulders\", \"knees\", \"toes\"], 2), [\"head\", \"shoulders\", \"claw\", \"tentacle\", \"knees\", \"toes\"], 'frankenSplice([\"claw\", \"tentacle\"], [\"head\", \"shoulders\", \"knees\", \"toes\"], 2) 应该返回 [\"head\", \"shoulders\", \"claw\", \"tentacle\", \"knees\", \"toes\"]。');" }, { - "text": "All elements from the first array should be added to the second array in their original order.", - "testString": "assert.deepEqual(frankenSplice([1, 2, 3, 4], [], 0), [1, 2, 3, 4], 'All elements from the first array should be added to the second array in their original order.');" + "text": "来自第一个数组的所有元素应该按原来的顺序被插入到第二个数组中。", + "testString": "assert.deepEqual(frankenSplice([1, 2, 3, 4], [], 0), [1, 2, 3, 4], '来自第一个数组的所有元素应该按原来的顺序被插入到第二个数组中。');" }, { - "text": "The first array should remain the same after the function runs.", - "testString": "assert(testArr1[0] === 1 && testArr1[1] === 2, 'The first array should remain the same after the function runs.');" + "text": "第一个数组在函数执行前后应该保持一样。", + "testString": "assert(testArr1[0] === 1 && testArr1[1] === 2, '第一个数组在函数执行前后应该保持一样。');" }, { - "text": "The second array should remain the same after the function runs.", - "testString": "assert(testArr2[0] === \"a\" && testArr2[1] === \"b\", 'The second array should remain the same after the function runs.');" + "text": "第二个数组在函数执行前后应该保持一样。", + "testString": "assert(testArr2[0] === \"a\" && testArr2[1] === \"b\", '第二个数组在函数执行前后应该保持一样。');" } ], "isRequired": true, @@ -732,27 +732,27 @@ "id": "adf08ec01beb4f99fc7a68f2", "title": "Falsy Bouncer", "description": [ - "Remove all falsy values from an array.", - "Falsy values in JavaScript are false, null, 0, \"\", undefined, and NaN.", - "Hint: Try converting each value to a Boolean.", - "Remember to use Read-Search-Ask if you get stuck. Write your own code." + "从一个数组中移除所有假值(falsy values)。", + "JavaScript 中的假值有 falsenull0\"\"undefinedNaN。", + "提示:请尝试将每一个值转换为一个布尔值(boolean)。", + "如果您有任何疑问,可以访问 Read-Search-Ask 。请您独立解决挑战中的问题。" ], "tests": [ { - "text": "bouncer([7, \"ate\", \"\", false, 9]) should return [7, \"ate\", 9].", - "testString": "assert.deepEqual(bouncer([7, \"ate\", \"\", false, 9]), [7, \"ate\", 9], 'bouncer([7, \"ate\", \"\", false, 9]) should return [7, \"ate\", 9].');" + "text": "bouncer([7, \"ate\", \"\", false, 9]) 应该返回 [7, \"ate\", 9]。", + "testString": "assert.deepEqual(bouncer([7, \"ate\", \"\", false, 9]), [7, \"ate\", 9], 'bouncer([7, \"ate\", \"\", false, 9]) 应该返回 [7, \"ate\", 9]。');" }, { - "text": "bouncer([\"a\", \"b\", \"c\"]) should return [\"a\", \"b\", \"c\"].", - "testString": "assert.deepEqual(bouncer([\"a\", \"b\", \"c\"]), [\"a\", \"b\", \"c\"], 'bouncer([\"a\", \"b\", \"c\"]) should return [\"a\", \"b\", \"c\"].');" + "text": "bouncer([\"a\", \"b\", \"c\"]) 应该返回 [\"a\", \"b\", \"c\"]。", + "testString": "assert.deepEqual(bouncer([\"a\", \"b\", \"c\"]), [\"a\", \"b\", \"c\"], 'bouncer([\"a\", \"b\", \"c\"]) 应该返回 [\"a\", \"b\", \"c\"]。');" }, { - "text": "bouncer([false, null, 0, NaN, undefined, \"\"]) should return [].", - "testString": "assert.deepEqual(bouncer([false, null, 0, NaN, undefined, \"\"]), [], 'bouncer([false, null, 0, NaN, undefined, \"\"]) should return [].');" + "text": "bouncer([false, null, 0, NaN, undefined, \"\"]) 应该返回 []。", + "testString": "assert.deepEqual(bouncer([false, null, 0, NaN, undefined, \"\"]), [], 'bouncer([false, null, 0, NaN, undefined, \"\"]) 应该返回 []。');" }, { - "text": "bouncer([1, null, NaN, 2, undefined]) should return [1, 2].", - "testString": "assert.deepEqual(bouncer([1, null, NaN, 2, undefined]), [1, 2], 'bouncer([1, null, NaN, 2, undefined]) should return [1, 2].');" + "text": "bouncer([1, null, NaN, 2, undefined]) 应该返回 [1, 2]。", + "testString": "assert.deepEqual(bouncer([1, null, NaN, 2, undefined]), [1, 2], 'bouncer([1, null, NaN, 2, undefined]) 应该返回 [1, 2]。');" } ], "isRequired": true, @@ -786,75 +786,75 @@ "id": "a24c1a4622e3c05097f71d67", "title": "Where do I Belong", "description": [ - "Return the lowest index at which a value (second argument) should be inserted into an array (first argument) once it has been sorted. The returned value should be a number.", - "For example, getIndexToIns([1,2,3,4], 1.5) should return 1 because it is greater than 1 (index 0), but less than 2 (index 1).", - "Likewise, getIndexToIns([20,3,5], 19) should return 2 because once the array has been sorted it will look like [3,5,20] and 19 is less than 20 (index 2) and greater than 5 (index 1).", - "Remember to use Read-Search-Ask if you get stuck. Write your own code." + "返回数组(第一个参数)被排序后,将一个值(第二个参数)插入到该数组中而使数组保持有序的最小的索引。返回的值应该是一个数字。", + "例如,getIndexToIns([1,2,3,4], 1.5) 应该返回 1 因为 1.5 大于 1 (索引为 0),但小于 2(索引为 1)。", + "同样地,getIndexToIns([20,3,5], 19) 应该返回 2 因为数组被排序后会变成 [3,5,20],而 19 小于 20(索引为 2)且大于 5(索引为 1)。", + "如果您有任何疑问,可以访问 Read-Search-Ask 。请您独立解决挑战中的问题。" ], "tests": [ { - "text": "getIndexToIns([10, 20, 30, 40, 50], 35) should return 3.", - "testString": "assert(getIndexToIns([10, 20, 30, 40, 50], 35) === 3, 'getIndexToIns([10, 20, 30, 40, 50], 35) should return 3.');" + "text": "getIndexToIns([10, 20, 30, 40, 50], 35) 应该返回 3。", + "testString": "assert(getIndexToIns([10, 20, 30, 40, 50], 35) === 3, 'getIndexToIns([10, 20, 30, 40, 50], 35) 应该返回 3。');" }, { - "text": "getIndexToIns([10, 20, 30, 40, 50], 35) should return a number.", - "testString": "assert(typeof(getIndexToIns([10, 20, 30, 40, 50], 35)) === \"number\", 'getIndexToIns([10, 20, 30, 40, 50], 35) should return a number.');" + "text": "getIndexToIns([10, 20, 30, 40, 50], 35) 应该返回一个数字。", + "testString": "assert(typeof(getIndexToIns([10, 20, 30, 40, 50], 35)) === \"number\", 'getIndexToIns([10, 20, 30, 40, 50], 35) 应该返回一个数字。');" }, { - "text": "getIndexToIns([10, 20, 30, 40, 50], 30) should return 2.", - "testString": "assert(getIndexToIns([10, 20, 30, 40, 50], 30) === 2, 'getIndexToIns([10, 20, 30, 40, 50], 30) should return 2.');" + "text": "getIndexToIns([10, 20, 30, 40, 50], 30) 应该返回 2。", + "testString": "assert(getIndexToIns([10, 20, 30, 40, 50], 30) === 2, 'getIndexToIns([10, 20, 30, 40, 50], 30) 应该返回 2。');" }, { - "text": "getIndexToIns([10, 20, 30, 40, 50], 30) should return a number.", - "testString": "assert(typeof(getIndexToIns([10, 20, 30, 40, 50], 30)) === \"number\", 'getIndexToIns([10, 20, 30, 40, 50], 30) should return a number.');" + "text": "getIndexToIns([10, 20, 30, 40, 50], 30) 应该返回一个数字。", + "testString": "assert(typeof(getIndexToIns([10, 20, 30, 40, 50], 30)) === \"number\", 'getIndexToIns([10, 20, 30, 40, 50], 30) 应该返回一个数字。');" }, { - "text": "getIndexToIns([40, 60], 50) should return 1.", - "testString": "assert(getIndexToIns([40, 60], 50) === 1, 'getIndexToIns([40, 60], 50) should return 1.');" + "text": "getIndexToIns([40, 60], 50) 应该返回 1。", + "testString": "assert(getIndexToIns([40, 60], 50) === 1, 'getIndexToIns([40, 60], 50) 应该返回 1。');" }, { - "text": "getIndexToIns([40, 60], 50) should return a number.", - "testString": "assert(typeof(getIndexToIns([40, 60], 50)) === \"number\", 'getIndexToIns([40, 60], 50) should return a number.');" + "text": "getIndexToIns([40, 60], 50) 应该返回一个数字。", + "testString": "assert(typeof(getIndexToIns([40, 60], 50)) === \"number\", 'getIndexToIns([40, 60], 50) 应该返回一个数字。');" }, { - "text": "getIndexToIns([3, 10, 5], 3) should return 0.", - "testString": "assert(getIndexToIns([3, 10, 5], 3) === 0, 'getIndexToIns([3, 10, 5], 3) should return 0.');" + "text": "getIndexToIns([3, 10, 5], 3) 应该返回 0。", + "testString": "assert(getIndexToIns([3, 10, 5], 3) === 0, 'getIndexToIns([3, 10, 5], 3) 应该返回 0。');" }, { - "text": "getIndexToIns([3, 10, 5], 3) should return a number.", - "testString": "assert(typeof(getIndexToIns([3, 10, 5], 3)) === \"number\", 'getIndexToIns([3, 10, 5], 3) should return a number.');" + "text": "getIndexToIns([3, 10, 5], 3) 应该返回一个数字。", + "testString": "assert(typeof(getIndexToIns([3, 10, 5], 3)) === \"number\", 'getIndexToIns([3, 10, 5], 3) 应该返回一个数字。');" }, { - "text": "getIndexToIns([5, 3, 20, 3], 5) should return 2.", - "testString": "assert(getIndexToIns([5, 3, 20, 3], 5) === 2, 'getIndexToIns([5, 3, 20, 3], 5) should return 2.');" + "text": "getIndexToIns([5, 3, 20, 3], 5) 应该返回 2。", + "testString": "assert(getIndexToIns([5, 3, 20, 3], 5) === 2, 'getIndexToIns([5, 3, 20, 3], 5) 应该返回 2。');" }, { - "text": "getIndexToIns([5, 3, 20, 3], 5) should return a number.", - "testString": "assert(typeof(getIndexToIns([5, 3, 20, 3], 5)) === \"number\", 'getIndexToIns([5, 3, 20, 3], 5) should return a number.');" + "text": "getIndexToIns([5, 3, 20, 3], 5) 应该返回一个数字。", + "testString": "assert(typeof(getIndexToIns([5, 3, 20, 3], 5)) === \"number\", 'getIndexToIns([5, 3, 20, 3], 5) 应该返回一个数字。');" }, { - "text": "getIndexToIns([2, 20, 10], 19) should return 2.", - "testString": "assert(getIndexToIns([2, 20, 10], 19) === 2, 'getIndexToIns([2, 20, 10], 19) should return 2.');" + "text": "getIndexToIns([2, 20, 10], 19) 应该返回 2。", + "testString": "assert(getIndexToIns([2, 20, 10], 19) === 2, 'getIndexToIns([2, 20, 10], 19) 应该返回 2。');" }, { - "text": "getIndexToIns([2, 20, 10], 19) should return a number.", - "testString": "assert(typeof(getIndexToIns([2, 20, 10], 19)) === \"number\", 'getIndexToIns([2, 20, 10], 19) should return a number.');" + "text": "getIndexToIns([2, 20, 10], 19) 应该返回一个数字。", + "testString": "assert(typeof(getIndexToIns([2, 20, 10], 19)) === \"number\", 'getIndexToIns([2, 20, 10], 19) 应该返回一个数字。');" }, { - "text": "getIndexToIns([2, 5, 10], 15) should return 3.", - "testString": "assert(getIndexToIns([2, 5, 10], 15) === 3, 'getIndexToIns([2, 5, 10], 15) should return 3.');" + "text": "getIndexToIns([2, 5, 10], 15) 应该返回 3。", + "testString": "assert(getIndexToIns([2, 5, 10], 15) === 3, 'getIndexToIns([2, 5, 10], 15) 应该返回 3。');" }, { - "text": "getIndexToIns([2, 5, 10], 15) should return a number.", - "testString": "assert(typeof(getIndexToIns([2, 5, 10], 15)) === \"number\", 'getIndexToIns([2, 5, 10], 15) should return a number.');" + "text": "getIndexToIns([2, 5, 10], 15) 应该返回一个数字。", + "testString": "assert(typeof(getIndexToIns([2, 5, 10], 15)) === \"number\", 'getIndexToIns([2, 5, 10], 15) 应该返回一个数字。');" }, { - "text": "getIndexToIns([], 1) should return 0.", - "testString": "assert(getIndexToIns([], 1) === 0, 'getIndexToIns([], 1) should return 0.');" + "text": "getIndexToIns([], 1) 应该返回 0。", + "testString": "assert(getIndexToIns([], 1) === 0, 'getIndexToIns([], 1) 应该返回 0。');" }, { - "text": "getIndexToIns([], 1) should return a number.", - "testString": "assert(typeof(getIndexToIns([], 1)) === \"number\", 'getIndexToIns([], 1) should return a number.');" + "text": "getIndexToIns([], 1) 应该返回一个数字。", + "testString": "assert(typeof(getIndexToIns([], 1)) === \"number\", 'getIndexToIns([], 1) 应该返回一个数字。');" } ], "isRequired": true, @@ -887,48 +887,48 @@ "id": "af2170cad53daa0770fabdea", "title": "Mutations", "description": [ - "Return true if the string in the first element of the array contains all of the letters of the string in the second element of the array.", - "For example, [\"hello\", \"Hello\"], should return true because all of the letters in the second string are present in the first, ignoring case.", - "The arguments [\"hello\", \"hey\"] should return false because the string \"hello\" does not contain a \"y\".", - "Lastly, [\"Alien\", \"line\"], should return true because all of the letters in \"line\" are present in \"Alien\".", - "Remember to use Read-Search-Ask if you get stuck. Write your own code." + "输入参数是一个有两个字符串元素的数组。如果第一个字符串中包含了第二个字符串中的所有字母,则返回 true。", + "例如,[\"hello\", \"Hello\"] 应该返回 true 因为第一个字符串中包含了第二个字符串中出现的所有字母(忽略大小写)。", + "而 [\"hello\", \"hey\"] 应该返回 false 因为第一个字符串 \"hello\" 没有包含字母 \"y\"。", + "最后,[\"Alien\", \"line\"], 应该返回 true,因为 \"line\" 中的所有字母都被包含在 \"Alien\" 中。", + "如果您有任何疑问,可以访问 Read-Search-Ask 。请您独立解决挑战中的问题。" ], "tests": [ { - "text": "mutation([\"hello\", \"hey\"]) should return false.", - "testString": "assert(mutation([\"hello\", \"hey\"]) === false, 'mutation([\"hello\", \"hey\"]) should return false.');" + "text": "mutation([\"hello\", \"hey\"]) 应该返回 false。", + "testString": "assert(mutation([\"hello\", \"hey\"]) === false, 'mutation([\"hello\", \"hey\"]) 应该返回 false。');" }, { - "text": "mutation([\"hello\", \"Hello\"]) should return true.", - "testString": "assert(mutation([\"hello\", \"Hello\"]) === true, 'mutation([\"hello\", \"Hello\"]) should return true.');" + "text": "mutation([\"hello\", \"Hello\"]) 应该返回 true。", + "testString": "assert(mutation([\"hello\", \"Hello\"]) === true, 'mutation([\"hello\", \"Hello\"]) 应该返回 true。');" }, { - "text": "mutation([\"zyxwvutsrqponmlkjihgfedcba\", \"qrstu\"]) should return true.", - "testString": "assert(mutation([\"zyxwvutsrqponmlkjihgfedcba\", \"qrstu\"]) === true, 'mutation([\"zyxwvutsrqponmlkjihgfedcba\", \"qrstu\"]) should return true.');" + "text": "mutation([\"zyxwvutsrqponmlkjihgfedcba\", \"qrstu\"]) 应该返回 true。", + "testString": "assert(mutation([\"zyxwvutsrqponmlkjihgfedcba\", \"qrstu\"]) === true, 'mutation([\"zyxwvutsrqponmlkjihgfedcba\", \"qrstu\"]) 应该返回 true。');" }, { - "text": "mutation([\"Mary\", \"Army\"]) should return true.", - "testString": "assert(mutation([\"Mary\", \"Army\"]) === true, 'mutation([\"Mary\", \"Army\"]) should return true.');" + "text": "mutation([\"Mary\", \"Army\"]) 应该返回 true。", + "testString": "assert(mutation([\"Mary\", \"Army\"]) === true, 'mutation([\"Mary\", \"Army\"]) 应该返回 true。');" }, { - "text": "mutation([\"Mary\", \"Aarmy\"]) should return true.", - "testString": "assert(mutation([\"Mary\", \"Aarmy\"]) === true, 'mutation([\"Mary\", \"Aarmy\"]) should return true.');" + "text": "mutation([\"Mary\", \"Aarmy\"]) 应该返回 true。", + "testString": "assert(mutation([\"Mary\", \"Aarmy\"]) === true, 'mutation([\"Mary\", \"Aarmy\"]) 应该返回 true。');" }, { - "text": "mutation([\"Alien\", \"line\"]) should return true.", - "testString": "assert(mutation([\"Alien\", \"line\"]) === true, 'mutation([\"Alien\", \"line\"]) should return true.');" + "text": "mutation([\"Alien\", \"line\"]) 应该返回 true。", + "testString": "assert(mutation([\"Alien\", \"line\"]) === true, 'mutation([\"Alien\", \"line\"]) 应该返回 true。');" }, { - "text": "mutation([\"floor\", \"for\"]) should return true.", - "testString": "assert(mutation([\"floor\", \"for\"]) === true, 'mutation([\"floor\", \"for\"]) should return true.');" + "text": "mutation([\"floor\", \"for\"]) 应该返回 true。", + "testString": "assert(mutation([\"floor\", \"for\"]) === true, 'mutation([\"floor\", \"for\"]) 应该返回 true。');" }, { - "text": "mutation([\"hello\", \"neo\"]) should return false.", - "testString": "assert(mutation([\"hello\", \"neo\"]) === false, 'mutation([\"hello\", \"neo\"]) should return false.');" + "text": "mutation([\"hello\", \"neo\"]) 应该返回 false。", + "testString": "assert(mutation([\"hello\", \"neo\"]) === false, 'mutation([\"hello\", \"neo\"]) 应该返回 false。');" }, { - "text": "mutation([\"voodoo\", \"no\"]) should return false.", - "testString": "assert(mutation([\"voodoo\", \"no\"]) === false, 'mutation([\"voodoo\", \"no\"]) should return false.');" + "text": "mutation([\"voodoo\", \"no\"]) 应该返回 false。", + "testString": "assert(mutation([\"voodoo\", \"no\"]) === false, 'mutation([\"voodoo\", \"no\"]) 应该返回 false。');" } ], "isRequired": true, @@ -960,37 +960,37 @@ "id": "a9bd25c716030ec90084d8a1", "title": "Chunky Monkey", "description": [ - "Write a function that splits an array (first argument) into groups the length of size (second argument) and returns them as a two-dimensional array.", - "Remember to use Read-Search-Ask if you get stuck. Write your own code." + "请写一个函数,将一个数组(第一个参数)分割成一组长度为 size(第二个参数)的数组,然后在一个二维数组中返回这些结果。", + "如果您有任何疑问,可以访问 Read-Search-Ask 。请您独立解决挑战中的问题。" ], "tests": [ { - "text": "chunkArrayInGroups([\"a\", \"b\", \"c\", \"d\"], 2) should return [[\"a\", \"b\"], [\"c\", \"d\"]].", - "testString": "assert.deepEqual(chunkArrayInGroups([\"a\", \"b\", \"c\", \"d\"], 2), [[\"a\", \"b\"], [\"c\", \"d\"]], 'chunkArrayInGroups([\"a\", \"b\", \"c\", \"d\"], 2) should return [[\"a\", \"b\"], [\"c\", \"d\"]].');" + "text": "chunkArrayInGroups([\"a\", \"b\", \"c\", \"d\"], 2) 应该返回 [[\"a\", \"b\"], [\"c\", \"d\"]]。", + "testString": "assert.deepEqual(chunkArrayInGroups([\"a\", \"b\", \"c\", \"d\"], 2), [[\"a\", \"b\"], [\"c\", \"d\"]], 'chunkArrayInGroups([\"a\", \"b\", \"c\", \"d\"], 2) 应该返回 [[\"a\", \"b\"], [\"c\", \"d\"]]。');" }, { - "text": "chunkArrayInGroups([0, 1, 2, 3, 4, 5], 3) should return [[0, 1, 2], [3, 4, 5]].", - "testString": "assert.deepEqual(chunkArrayInGroups([0, 1, 2, 3, 4, 5], 3), [[0, 1, 2], [3, 4, 5]], 'chunkArrayInGroups([0, 1, 2, 3, 4, 5], 3) should return [[0, 1, 2], [3, 4, 5]].');" + "text": "chunkArrayInGroups([0, 1, 2, 3, 4, 5], 3) 应该返回 [[0, 1, 2], [3, 4, 5]]。", + "testString": "assert.deepEqual(chunkArrayInGroups([0, 1, 2, 3, 4, 5], 3), [[0, 1, 2], [3, 4, 5]], 'chunkArrayInGroups([0, 1, 2, 3, 4, 5], 3) 应该返回 [[0, 1, 2], [3, 4, 5]]。');" }, { - "text": "chunkArrayInGroups([0, 1, 2, 3, 4, 5], 2) should return [[0, 1], [2, 3], [4, 5]].", - "testString": "assert.deepEqual(chunkArrayInGroups([0, 1, 2, 3, 4, 5], 2), [[0, 1], [2, 3], [4, 5]], 'chunkArrayInGroups([0, 1, 2, 3, 4, 5], 2) should return [[0, 1], [2, 3], [4, 5]].');" + "text": "chunkArrayInGroups([0, 1, 2, 3, 4, 5], 2) 应该返回 [[0, 1], [2, 3], [4, 5]]。", + "testString": "assert.deepEqual(chunkArrayInGroups([0, 1, 2, 3, 4, 5], 2), [[0, 1], [2, 3], [4, 5]], 'chunkArrayInGroups([0, 1, 2, 3, 4, 5], 2) 应该返回 [[0, 1], [2, 3], [4, 5]]。');" }, { - "text": "chunkArrayInGroups([0, 1, 2, 3, 4, 5], 4) should return [[0, 1, 2, 3], [4, 5]].", - "testString": "assert.deepEqual(chunkArrayInGroups([0, 1, 2, 3, 4, 5], 4), [[0, 1, 2, 3], [4, 5]], 'chunkArrayInGroups([0, 1, 2, 3, 4, 5], 4) should return [[0, 1, 2, 3], [4, 5]].');" + "text": "chunkArrayInGroups([0, 1, 2, 3, 4, 5], 4) 应该返回 [[0, 1, 2, 3], [4, 5]]。", + "testString": "assert.deepEqual(chunkArrayInGroups([0, 1, 2, 3, 4, 5], 4), [[0, 1, 2, 3], [4, 5]], 'chunkArrayInGroups([0, 1, 2, 3, 4, 5], 4) 应该返回 [[0, 1, 2, 3], [4, 5]]。');" }, { - "text": "chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6], 3) should return [[0, 1, 2], [3, 4, 5], [6]].", - "testString": "assert.deepEqual(chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6], 3), [[0, 1, 2], [3, 4, 5], [6]], 'chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6], 3) should return [[0, 1, 2], [3, 4, 5], [6]].');" + "text": "chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6], 3) 应该返回 [[0, 1, 2], [3, 4, 5], [6]]。", + "testString": "assert.deepEqual(chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6], 3), [[0, 1, 2], [3, 4, 5], [6]], 'chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6], 3) 应该返回 [[0, 1, 2], [3, 4, 5], [6]]。');" }, { - "text": "chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6, 7, 8], 4) should return [[0, 1, 2, 3], [4, 5, 6, 7], [8]].", - "testString": "assert.deepEqual(chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6, 7, 8], 4), [[0, 1, 2, 3], [4, 5, 6, 7], [8]], 'chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6, 7, 8], 4) should return [[0, 1, 2, 3], [4, 5, 6, 7], [8]].');" + "text": "chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6, 7, 8], 4) 应该返回 [[0, 1, 2, 3], [4, 5, 6, 7], [8]]。", + "testString": "assert.deepEqual(chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6, 7, 8], 4), [[0, 1, 2, 3], [4, 5, 6, 7], [8]], 'chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6, 7, 8], 4) 应该返回 [[0, 1, 2, 3], [4, 5, 6, 7], [8]]。');" }, { - "text": "chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6, 7, 8], 2) should return [[0, 1], [2, 3], [4, 5], [6, 7], [8]].", - "testString": "assert.deepEqual(chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6, 7, 8], 2), [[0, 1], [2, 3], [4, 5], [6, 7], [8]], 'chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6, 7, 8], 2) should return [[0, 1], [2, 3], [4, 5], [6, 7], [8]].');" + "text": "chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6, 7, 8], 2) 应该返回 [[0, 1], [2, 3], [4, 5], [6, 7], [8]]。", + "testString": "assert.deepEqual(chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6, 7, 8], 2), [[0, 1], [2, 3], [4, 5], [6, 7], [8]], 'chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6, 7, 8], 2) 应该返回 [[0, 1], [2, 3], [4, 5], [6, 7], [8]]。');" } ], "isRequired": true, @@ -1021,4 +1021,4 @@ } } ] -} \ No newline at end of file +} diff --git a/02-javascript-algorithms-and-data-structures/basic-data-structures.json b/02-javascript-algorithms-and-data-structures/basic-data-structures.json index 7cb29b1..0077390 100644 --- a/02-javascript-algorithms-and-data-structures/basic-data-structures.json +++ b/02-javascript-algorithms-and-data-structures/basic-data-structures.json @@ -8,34 +8,34 @@ "id": "587d7b7e367417b2b2512b20", "title": "Use an Array to Store a Collection of Data", "description": [ - "The below is an example of the simplest implementation of an array data structure. This is known as a one-dimensional array, meaning it only has one level, or that it does not have any other arrays nested within it. Notice it contains booleans, strings, and numbers, among other valid JavaScript data types:", + "以下是数组(Array)数据结构的最简单的实现的一个例子。这是一个 一维数组one-dimensional Array),它只有一层,或者说它里面没有包含其它的数组。您可以看到它包含了 布尔值booleans)、字符串strings)、数字numbers) 以及 JavaScript 中其他合法的数据类型:", "
let simpleArray = ['one', 2, 'three’, true, false, undefined, null];
console.log(simpleArray.length);
// logs 7
", - "All array's have a length property, which as shown above, can be very easily accessed with the syntax Array.length.", - "A more complex implementation of an array can be seen below. This is known as a multi-dimensional array, or an array that contains other arrays. Notice that this array also contains JavaScript objects, which we will examine very closely in our next section, but for now, all you need to know is that arrays are also capable of storing complex objects.", + "您可以在上述例子中看到,所有数组都有一个长度(length)属性。您可以简单地使用 Array.length 方法来访问它。", + "下面是一个更复杂一点的数组的例子。这是一个 多维数组multi-dimensional Array),或者说是一个包含了其他数组的数组。您可以注意到,它还包含了 JavaScript 中的 对象objects)。我们会在接下来的一节中讨论 JavaScript 对象变量,但现在您只需要知道数组能够存储复杂的对象。", "
let complexArray = [
  [
    {
      one: 1,
      two: 2
    },
    {
      three: 3,
      four: 4
    }
  ],
  [
    {
      a: \"a\",
      b: \"b\"
    },
    {
      c: \"c\",
      d: “d”
    }
  ]
];
", "
", - "We have defined a variable called yourArray. Complete the statement by assigning an array of at least 5 elements in length to the yourArray variable. Your array should contain at least one string, one number, and one boolean." + "我们已经定义了一个 yourArray 变量。请修改题目中的语句,将一个含有至少5个元素的数组赋值给 yourArray 变量。您的数组应该包含至少一个 string、一个 number 和一个 boolean。" ], "tests": [ { - "text": "yourArray is an array", - "testString": "assert.strictEqual(Array.isArray(yourArray), true, 'yourArray is an array');" + "text": "yourArray 应该是一个数组。", + "testString": "assert.strictEqual(Array.isArray(yourArray), true, 'yourArray 应该是一个数组。');" }, { - "text": "yourArray is at least 5 elements long", - "testString": "assert.isAtLeast(yourArray.length, 5, 'yourArray is at least 5 elements long');" + "text": "yourArray 至少要包含5个元素。", + "testString": "assert.isAtLeast(yourArray.length, 5, 'yourArray 至少要包含5个元素。');" }, { - "text": "yourArray contains at least one boolean", - "testString": "assert(yourArray.filter( el => typeof el === 'boolean').length >= 1, 'yourArray contains at least one boolean');" + "text": "yourArray 应该包含至少一个 boolean。", + "testString": "assert(yourArray.filter( el => typeof el === 'boolean').length >= 1, 'yourArray 应该包含至少一个 boolean。');" }, { - "text": "yourArray contains at least one number", - "testString": "assert(yourArray.filter( el => typeof el === 'number').length >= 1, 'yourArray contains at least one number');" + "text": "yourArray 应该包含至少一个 number。", + "testString": "assert(yourArray.filter( el => typeof el === 'number').length >= 1, 'yourArray 应该包含至少一个 number。');" }, { - "text": "yourArray contains at least one string", - "testString": "assert(yourArray.filter( el => typeof el === 'string').length >= 1, 'yourArray contains at least one string');" + "text": "yourArray 应该包含至少一个 string。", + "testString": "assert(yourArray.filter( el => typeof el === 'string').length >= 1, 'yourArray 应该包含至少一个 string。');" } ], "releasedOn": "Feb 17, 2017", @@ -58,35 +58,35 @@ "id": "5a661e0f1068aca922b3ef17", "title": "Access an Array's Contents Using Bracket Notation", "description": [ - "The fundamental feature of any data structure is, of course, the ability to not only store data, but to be able to retrieve that data on command. So, now that we've learned how to create an array, let's begin to think about how we can access that array's information.", - "When we define a simple array as seen below, there are 3 items in it:", + "所有数据结构的基本特性是,不仅能够存储数据,还能够按需从中获取这些数据。我们已经学习了如何创建一个数组,现在让我们开始考虑如何访问数据中的信息。", + "我们先定义一个包含 3 个元素的数组:", "
let ourArray = [\"a\", \"b\", \"c\"];
", - "In an array, each array item has an index. This index doubles as the position of that item in the array, and how you reference it. However, it is important to note, that JavaScript arrays are zero-indexed, meaning that the first element of an array is actually at the zeroth position, not the first.", - "In order to retrieve an element from an array we can enclose an index in brackets and append it to the end of an array, or more commonly, to a variable which references an array object. This is known as bracket notation.", - "For example, if we want to retrieve the \"a\" from ourArray and assign it to a variable, we can do so with the following code:", + "在一个数组里,每个元素都有一个 索引index)。索引是该元素在数组中的位置,可被用于引用该元素。但是您要注意,JavaScript 数组的索引是从0开始的(zero-indexed),即一个数组的第一个元素是在数组中的 第0个 位置而不是第一个位置。", + "要从一个数组中获取一个元素,我们可以在一个数组变量名的后面加一个用方括号括起来的索引。这叫做 方括号符号bracket notation)。", + "例如我们要从 ourArray 中获取 \"a\" 并将它赋值给一个变量,我们可以编写如下代码:", "
let ourVariable = ourArray[0];
// ourVariable equals \"a\"
", - "In addition to accessing the value associated with an index, you can also set an index to a value using the same notation:", + "除了用索引来获取一个元素的值,您还可以用方括号符号 设置 一个索引对应的元素的值:", "
ourArray[1] = \"not b anymore\";
// ourArray now equals [\"a\", \"not b anymore\", \"c\"];
", - "Using bracket notation, we have now reset the item at index 1 from \"b\", to \"not b anymore\".", + "我们现在已经利用方括号将索引为 1 的元素从 \"b\" 设置为了 \"not b anymore\"。", "
", - "In order to complete this challenge, set the 2nd position (index 1) of myArray to anything you want, besides \"b\"." + "在本挑战中,请您将 myArray 中第二个元素(索引 1)设置为除了 \"b\" 以外的任意值。" ], "tests": [ { - "text": "myArray[0] is equal to \"a\"", - "testString": "assert.strictEqual(myArray[0], \"a\", 'myArray[0] is equal to \"a\"');" + "text": "myArray[0] 必须等于 \"a\"。", + "testString": "assert.strictEqual(myArray[0], \"a\", 'myArray[0] 必须等于 \"a\"。');" }, { - "text": "myArray[1] is no longer set to \"b\"", - "testString": "assert.notStrictEqual(myArray[1], \"b\", 'myArray[1] is no longer set to \"b\"');" + "text": "myArray[1] 不能再等于 \"b\"。", + "testString": "assert.notStrictEqual(myArray[1], \"b\", 'myArray[1] 不能再等于 \"b\"。');" }, { - "text": "myArray[2] is equal to \"c\"", - "testString": "assert.strictEqual(myArray[2], \"c\", 'myArray[2] is equal to \"c\"');" + "text": "myArray[2] 必须等于 \"c\"。", + "testString": "assert.strictEqual(myArray[2], \"c\", 'myArray[2] 必须等于 \"c\"。');" }, { - "text": "myArray[3] is equal to \"d\"", - "testString": "assert.strictEqual(myArray[3], \"d\", 'myArray[3] is equal to \"d\"');" + "text": "myArray[3] 必须等于 \"d\"。", + "testString": "assert.strictEqual(myArray[3], \"d\", 'myArray[3] 必须等于 \"d\"。');" } ], "solutions": [], @@ -112,25 +112,25 @@ "id": "587d78b2367417b2b2512b0e", "title": "Add Items to an Array with push() and unshift()", "description": [ - "An array's length, like the data types it can contain, is not fixed. Arrays can be defined with a length of any number of elements, and elements can be added or removed over time; in other words, arrays are mutable. In this challenge, we will look at two methods with which we can programmatically modify an array: Array.push() and Array.unshift(). ", - "Both methods take one or more elements as parameters and add those elements to the array the method is being called on; the push() method adds elements to the end of an array, and unshift() adds elements to the beginning. Consider the following:", + "一个数组的长度与其包含的数据类型一样,是不固定的。数组可以包含任意数量的元素,您可以不限次数地往数组中添加元素或者从中移除元素,或者说数组是 可变的mutable)。在本挑战中,我们要学习两个以编程方式修改数组的方法: Array.push()Array.unshift()。", + "这两个方法的输入参数都可以是一个或多个元素;对一个数组调用这两个方法都可以将输入的元素插入到该数组中;push() 方法将元素插入到一个数组的末尾,而 unshift() 方法将元素插入到一个数组的开头。请看以下例子:", "
let twentyThree = 'XXIII';
let romanNumerals = ['XXI', 'XXII'];

romanNumerals.unshift('XIX', 'XX');
// now equals ['XIX', 'XX', 'XXI', 'XXII']

romanNumerals.push(twentyThree);
// now equals ['XIX', 'XX', 'XXI', 'XXII', 'XXIII']", - "Notice that we can also pass variables, which allows us even greater flexibility in dynamically modifying our array's data.", + "注意,我们还可以输入变量,这允许我们很灵活地动态改变我们数组中的数据。", "
", - "We have defined a function, mixedNumbers, which we are passing an array as an argument. Modify the function by using push() and unshift() to add 'I', 2, 'three' to the beginning of the array and 7, 'VIII', 9 to the end so that the returned array contains representations of the numbers 1-9 in order." + "我们已经定义了一个 mixedNumbers 函数,它会接受一个数组作为输入参数。请您修改这个函数,使用 push()unshift() 来将 'I', 2, 'three' 插入到输入的数组的开头,将 7, 'VIII', 9 插入到数组的末尾,使得这个函数返回一个依次包含 1-9 的数组。" ], "tests": [ { - "text": "mixedNumbers([\"IV\", 5, \"six\"]) should now return [\"I\", 2, \"three\", \"IV\", 5, \"six\", 7, \"VIII\", 9]", - "testString": "assert.deepEqual(mixedNumbers(['IV', 5, 'six']), ['I', 2, 'three', 'IV', 5, 'six', 7, 'VIII', 9], 'mixedNumbers([\"IV\", 5, \"six\"]) should now return [\"I\", 2, \"three\", \"IV\", 5, \"six\", 7, \"VIII\", 9]');" + "text": "mixedNumbers([\"IV\", 5, \"six\"]) 现在应该返回 [\"I\", 2, \"three\", \"IV\", 5, \"six\", 7, \"VIII\", 9]。", + "testString": "assert.deepEqual(mixedNumbers(['IV', 5, 'six']), ['I', 2, 'three', 'IV', 5, 'six', 7, 'VIII', 9], 'mixedNumbers([\"IV\", 5, \"six\"]) 现在应该返回 [\"I\", 2, \"three\", \"IV\", 5, \"six\", 7, \"VIII\", 9]。');" }, { - "text": "The mixedNumbers function should utilize the push() method", - "testString": "assert.notStrictEqual(mixedNumbers.toString().search(/\\.push\\(/), -1, 'The mixedNumbers function should utilize the push() method');" + "text": "mixedNumbers 函数中应该用到 push() 方法。", + "testString": "assert.notStrictEqual(mixedNumbers.toString().search(/\\.push\\(/), -1, 'mixedNumbers 函数中应该用到 push() 方法。');" }, { - "text": "The mixedNumbers function should utilize the unshift() method", - "testString": "assert.notStrictEqual(mixedNumbers.toString().search(/\\.unshift\\(/), -1, 'The mixedNumbers function should utilize the unshift() method');" + "text": "mixedNumbers 函数中应该用到 unshift() 方法。", + "testString": "assert.notStrictEqual(mixedNumbers.toString().search(/\\.unshift\\(/), -1, 'mixedNumbers 函数中应该用到 unshift() 方法。');" } ], "releasedOn": "Feb 17, 2017", @@ -161,26 +161,26 @@ "id": "587d78b2367417b2b2512b0f", "title": "Remove Items from an Array with pop() and shift()", "description": [ - "Both push() and unshift() have corresponding methods that are nearly functional opposites: pop() and shift(). As you may have guessed by now, instead of adding, pop() removes an element from the end of an array, while shift() removes an element from the beginning. The key difference between pop() and shift() and their cousins push() and unshift(), is that neither method takes parameters, and each only allows an array to be modified by a single element at a time.", - "Let's take a look:", - "
let greetings = ['whats up?', 'hello', 'see ya!'];

greetings.pop();
// now equals ['whats up?', 'hello']

greetings.shift();
// now equals ['hello']
", - "We can also return the value of the removed element with either method like this:", - "
let popped = greetings.pop();
// returns 'hello'
// greetings now equals []
", + "push()unshift() 都分别有一个作用基本与之相反的函数:pop()shift()。您现在或许已经猜到,与插入元素相反,pop() 从数组的末尾 移除 一个元素,而 shift() 从数组的开头移除一个元素。pop()shift() 以及对应的 push()unshift() 的关键不同点是,前者不能接受输入参数,而且每次只能修改数组中的一个元素。", + "让我们来看如下例子:", + "
let greetings = ['whats up?', 'hello', 'see ya!'];

greetings.pop();
// 现在等于 ['whats up?', 'hello']

greetings.shift();
// 现在等于 ['hello']
", + "对于上述两个方法中的任意一个,我们都可以返回被其移除的元素:", + "
let popped = greetings.pop();
// 返回 'hello'
// greetings 现在等于 []
", "
", - "We have defined a function, popShift, which takes an array as an argument and returns a new array. Modify the function, using pop() and shift(), to remove the first and last elements of the argument array, and assign the removed elements to their corresponding variables, so that the returned array contains their values." + "我们已经定义了一个 popShift 函数,它会接收一个数组作为输入参数并返回一个新的数组。请您修改这个函数,使用 pop()shift() 来移除输入的数组的第一个元素和最后一个元素,并将这两个被移除的元素赋值给对应的变量,使得返回的数组包含它们的值。" ], "tests": [ { - "text": "popShift([\"challenge\", \"is\", \"not\", \"complete\"]) should return [\"challenge\", \"complete\"]", - "testString": "assert.deepEqual(popShift(['challenge', 'is', 'not', 'complete']), [\"challenge\", \"complete\"], 'popShift([\"challenge\", \"is\", \"not\", \"complete\"]) should return [\"challenge\", \"complete\"]');" + "text": "popShift([\"challenge\", \"is\", \"not\", \"complete\"]) 应该返回 [\"challenge\", \"complete\"]。", + "testString": "assert.deepEqual(popShift(['challenge', 'is', 'not', 'complete']), [\"challenge\", \"complete\"], 'popShift([\"challenge\", \"is\", \"not\", \"complete\"]) 应该返回 [\"challenge\", \"complete\"]。');" }, { - "text": "The popShift function should utilize the pop() method", - "testString": "assert.notStrictEqual(popShift.toString().search(/\\.pop\\(/), -1, 'The popShift function should utilize the pop() method');" + "text": "popShift 函数应该用到 pop() 方法。", + "testString": "assert.notStrictEqual(popShift.toString().search(/\\.pop\\(/), -1, 'popShift 函数应该用到 pop() 方法。');" }, { - "text": "The popShift function should utilize the shift() method", - "testString": "assert.notStrictEqual(popShift.toString().search(/\\.shift\\(/), -1, 'The popShift function should utilize the shift() method');" + "text": "popShift 函数应该用到 shift() 方法。", + "testString": "assert.notStrictEqual(popShift.toString().search(/\\.shift\\(/), -1, 'popShift 函数应该用到 shift() 方法。');" } ], "releasedOn": "Feb 17, 2017", @@ -210,22 +210,22 @@ "id": "587d78b2367417b2b2512b10", "title": "Remove Items Using splice()", "description": [ - "Ok, so we've learned how to remove elements from the beginning and end of arrays using shift() and pop(), but what if we want to remove an element from somewhere in the middle? Or remove more than one element at once? Well, that's where splice() comes in. splice() allows us to do just that: remove any number of consecutive elements from anywhere in an array.", - "splice() can take up to 3 parameters, but for now, we'll focus on just the first 2. The first two parameters of splice() are integers which represent indexes, or positions, of the array that splice() is being called upon. And remember, arrays are zero-indexed, so to indicate the first element of an array, we would use 0. splice()'s first parameter represents the index on the array from which to begin removing elements, while the second parameter indicates the number of elements to delete. For example:", - "
let array = ['today', 'was', 'not', 'so', 'great'];

array.splice(2, 2);
// remove 2 elements beginning with the 3rd element
// array now equals ['today', 'was', 'great']
", - "splice() not only modifies the array it's being called on, but it also returns a new array containing the value of the removed elements:", - "
let array = ['I', 'am', 'feeling', 'really', 'happy'];

let newArray = array.splice(3, 2);
// newArray equals ['really', 'happy']
", + "Ok,我们已经学到了如何利用 shift()pop() 从数组的开头或者末尾移除元素,但如果我们想移除数组中间的一个元素呢?或者想一次移除多个元素呢?这时候我们就需要 splice() 了。splice() 让我们可以从数组中的任意位置 移除任意数量的连续的元素。", + "splice() 最多可以接受 3 个参数,但现在我们先关注前两个。splice() 的前两个参数是代表被调用 splice() 的数组中的索引或者位置的整数。记住,数组的索引是 从0开始的zero-indexed),所以我们要用 0 来指示数组中的第一个元素。splice() 的第一个参数代表从数组中的哪个索引开始移除元素,而第二个参数指示要从数组中删除多少个元素。例如:", + "
let array = ['today', 'was', 'not', 'so', 'great'];

array.splice(2, 2);
// 从第 3 个元素开始,删除 2 个元素
// 现在该数组等于 ['today', 'was', 'great']
", + "splice() 不仅从被调用的数组中移除元素,还会返回一个包含被移除元素的数组:", + "
let array = ['I', 'am', 'feeling', 'really', 'happy'];

let newArray = array.splice(3, 2);
// newArray 等于 ['really', 'happy']
", "
", - "We've defined a function, sumOfTen, which takes an array as an argument and returns the sum of that array's elements. Modify the function, using splice(), so that it returns a value of 10." + "我们已经定义了一个 sumOfTen 函数,它接受一个数组作为输入参数,并返回数组中所有元素的和。请您修改这个函数,利用 splice(),使得它返回 10。" ], "tests": [ { - "text": "sumOfTen should return 10", - "testString": "assert.strictEqual(sumOfTen([2, 5, 1, 5, 2, 1]), 10, 'sumOfTen should return 10');" + "text": "sumOfTen 应该返回 10。", + "testString": "assert.strictEqual(sumOfTen([2, 5, 1, 5, 2, 1]), 10, 'sumOfTen 应该返回 10。');" }, { - "text": "The sumOfTen function should utilize the splice() method", - "testString": "assert.notStrictEqual(sumOfTen.toString().search(/\\.splice\\(/), -1, 'The sumOfTen function should utilize the splice() method');" + "text": "sumOfTen 函数应该用到 splice() 方法。", + "testString": "assert.notStrictEqual(sumOfTen.toString().search(/\\.splice\\(/), -1, 'sumOfTen 函数应该用到 splice() 方法。');" } ], "releasedOn": "Feb 17, 2017", @@ -256,28 +256,28 @@ "id": "587d78b3367417b2b2512b11", "title": "Add Items Using splice()", "description": [ - "Remember in the last challenge we mentioned that splice() can take up to three parameters? Well, we can go one step further with splice() — in addition to removing elements, we can use that third parameter, which represents one or more elements, to add them as well. This can be incredibly useful for quickly switching out an element, or a set of elements, for another. For instance, let's say you're storing a color scheme for a set of DOM elements in an array, and want to dynamically change a color based on some action:", - "
function colorChange(arr, index, newColor) {
  arr.splice(index, 1, newColor);
  return arr;
}

let colorScheme = ['#878787', '#a08794', '#bb7e8c', '#c9b6be', '#d1becf'];

colorScheme = colorChange(colorScheme, 2, '#332327');
// we have removed '#bb7e8c' and added '#332327' in its place
// colorScheme now equals ['#878787', '#a08794', '#332327', '#c9b6be', '#d1becf']
", - "This function takes an array of hex values, an index at which to remove an element, and the new color to replace the removed element with. The return value is an array containing a newly modified color scheme! While this example is a bit oversimplified, we can see the value that utilizing splice() to its maximum potential can have.", + "您还记得在上个挑战中我们提到 splice() 方法可以接受最多 3 个参数吗?我们现在可以进一步了解 splice() —。除了移除元素,我们还可以利用它的第三个参数来向数组中 添加 元素。第三个参数可以是一个或多个元素,这些元素会被添加到数组中。这使我们能够便捷地将数组中的一个或一系列元素换成其他的元素。例如您在一个数组中存储了一系列 DOM 元素的配色,并希望基于某些行为动态地改变一个颜色:", + "
function colorChange(arr, index, newColor) {
  arr.splice(index, 1, newColor);
  return arr;
}

let colorScheme = ['#878787', '#a08794', '#bb7e8c', '#c9b6be', '#d1becf'];

colorScheme = colorChange(colorScheme, 2, '#332327');
// 我们移除了 '#bb7e8c' 并在其位置上添加了 '#332327'
// colorScheme 现在等于 ['#878787', '#a08794', '#332327', '#c9b6be', '#d1becf']
", + "这个函数接受一个十六进制值(hex value)的数组、要被移除的元素的索引以及要替换旧元素的新颜色作为输入参数。它的返回值是一个含有被修改的新的配色的数组。虽然这个例子可能过于简单,但我们还是能从中感受到充分利用 splice() 方法的价值。", "
", - "We have defined a function, htmlColorNames, which takes an array of HTML colors as an argument. Modify the function using splice() to remove the first two elements of the array and add 'DarkSalmon' and 'BlanchedAlmond' in their respective places." + "我们已经定义了一个 htmlColorNames 函数,它以一个 HTML 颜色的数组作为输入参数。请修改这个函数,利用 splice() 来移除数组中的前两个元素,并在对应的位置上添加 'DarkSalmon''BlanchedAlmond'。" ], "tests": [ { - "text": "htmlColorNames should return [\"DarkSalmon\", \"BlanchedAlmond\", \"LavenderBlush\", \"PaleTurqoise\", \"FireBrick\"]", - "testString": "assert.deepEqual(htmlColorNames(['DarkGoldenRod', 'WhiteSmoke', 'LavenderBlush', 'PaleTurqoise', 'FireBrick']), ['DarkSalmon', 'BlanchedAlmond', 'LavenderBlush', 'PaleTurqoise', 'FireBrick'], 'htmlColorNames should return [\"DarkSalmon\", \"BlanchedAlmond\", \"LavenderBlush\", \"PaleTurqoise\", \"FireBrick\"]');" + "text": "htmlColorNames 应该返回 [\"DarkSalmon\", \"BlanchedAlmond\", \"LavenderBlush\", \"PaleTurqoise\", \"FireBrick\"]。", + "testString": "assert.deepEqual(htmlColorNames(['DarkGoldenRod', 'WhiteSmoke', 'LavenderBlush', 'PaleTurqoise', 'FireBrick']), ['DarkSalmon', 'BlanchedAlmond', 'LavenderBlush', 'PaleTurqoise', 'FireBrick'], 'htmlColorNames 应该返回 [\"DarkSalmon\", \"BlanchedAlmond\", \"LavenderBlush\", \"PaleTurqoise\", \"FireBrick\"]。');" }, { - "text": "The htmlColorNames function should utilize the splice() method", - "testString": "assert(/.splice/.test(code), 'The htmlColorNames function should utilize the splice() method');" + "text": "htmlColorNames 函数中应该用到 splice() 方法。", + "testString": "assert(/.splice/.test(code), 'htmlColorNames 函数中应该用到 splice() 方法。');" }, { - "text": "You should not use shift() or unshift().", - "testString": "assert(!/shift|unshift/.test(code), 'You should not use shift() or unshift().');" + "text": "您不能使用 shift() 或者 unshift()。", + "testString": "assert(!/shift|unshift/.test(code), '您不能使用 shift() 或者 unshift()。');" }, { - "text": "You should not use array bracket notation.", - "testString": "assert(!/\\[\\d\\]\\s*=/.test(code), 'You should not use array bracket notation.');" + "text": "您不能使用数组的方括号符号。", + "testString": "assert(!/\\[\\d\\]\\s*=/.test(code), '您不能使用数组的方括号符号。');" } ], "releasedOn": "Feb 17, 2017", @@ -308,20 +308,20 @@ "id": "587d7b7a367417b2b2512b12", "title": "Copy Array Items Using slice()", "description": [ - "The next method we will cover is slice(). slice(), rather than modifying an array, copies, or extracts, a given number of elements to a new array, leaving the array it is called upon untouched. slice() takes only 2 parameters — the first is the index at which to begin extraction, and the second is the index at which to stop extraction (extraction will occur up to, but not including the element at this index). Consider this:", - "
let weatherConditions = ['rain', 'snow', 'sleet', 'hail', 'clear'];

let todaysWeather = weatherConditions.slice(1, 3);
// todaysWeather equals ['snow', 'sleet'];
// weatherConditions still equals ['rain', 'snow', 'sleet', 'hail', 'clear']
", - "In effect, we have created a new array by extracting elements from an existing array.", + "接下来我们要介绍 slice() 方法。slice() 并不修改数组,而是复制或者说 提取(extract) 给定数量的元素到一个新数组里,而被调用方法的数组则保持不变。slice() 只接受 2 个输入参数 — 第一个是开始提取元素的位置(索引),第二个是结束提取元素的位置(索引)(slice 方法会提取直到该索引的元素,但被提取的元素不包括该索引对应的元素)。请看以下例子:", + "
let weatherConditions = ['rain', 'snow', 'sleet', 'hail', 'clear'];

let todaysWeather = weatherConditions.slice(1, 3);
// todaysWeather 等于 ['snow', 'sleet'];
// weatherConditions 仍然等于 ['rain', 'snow', 'sleet', 'hail', 'clear']
", + "现在我们从一个已有的数组中提取了一些元素,并用这些元素创建了一个新数组。", "
", - "We have defined a function, forecast, that takes an array as an argument. Modify the function using slice() to extract information from the argument array and return a new array that contains the elements 'warm' and 'sunny'." + "我们已经定义了一个 forecast 函数,它接受一个数组作为输入参数。请修改这个函数,利用 slice() 来从输入的数组中提取信息,并返回一个包含元素 'warm''sunny' 的新数组。" ], "tests": [ { - "text": "forecast should return [\"warm\", \"sunny\"]", - "testString": "assert.deepEqual(forecast(['cold', 'rainy', 'warm', 'sunny', 'cool', 'thunderstorms']), ['warm', 'sunny'], 'forecast should return [\"warm\", \"sunny\"]');" + "text": "forecast 应该返回 [\"warm\", \"sunny\"]。", + "testString": "assert.deepEqual(forecast(['cold', 'rainy', 'warm', 'sunny', 'cool', 'thunderstorms']), ['warm', 'sunny'], 'forecast 应该返回 [\"warm\", \"sunny\"]。');" }, { - "text": "The forecast function should utilize the slice() method", - "testString": "assert(/\\.slice\\(/.test(code), 'The forecast function should utilize the slice() method');" + "text": "forecast 函数中应该用到 slice() 方法。", + "testString": "assert(/\\.slice\\(/.test(code), 'forecast 函数中应该用到 slice() 方法。');" } ], "releasedOn": "Feb 17, 2017", @@ -351,32 +351,32 @@ "id": "587d7b7b367417b2b2512b13", "title": "Copy an Array with the Spread Operator", "description": [ - "While slice() allows us to be selective about what elements of an array to copy, among several other useful tasks, ES6's new spread operator allows us to easily copy all of an array's elements, in order, with a simple and highly readable syntax. The spread syntax simply looks like this: ...", - "In practice, we can use the spread operator to copy an array like so:", - "
let thisArray = [true, true, undefined, false, null];
let thatArray = [...thisArray];
// thatArray equals [true, true, undefined, false, null]
// thisArray remains unchanged, and is identical to thatArray
", + "slice() 已经能让我们从一个数组中选择一些元素来复制到新数组中了,而 ES6 中又新引入了一个简洁且可读性强的语法 展开运算符(spread operator),它能让我们方便地复制数组中的 所有 元素。展开语法看起来是这样的:...", + "在实践中,我们可以这样用展开运算符来复制一个数组:", + "
let thisArray = [true, true, undefined, false, null];
let thatArray = [...thisArray];
// thatArray equals [true, true, undefined, false, null]
// thisArray 保持不变,并等于 thatArray
", "
", - "We have defined a function, copyMachine which takes arr (an array) and num (a number) as arguments. The function is supposed to return a new array made up of num copies of arr. We have done most of the work for you, but it doesn't work quite right yet. Modify the function using spread syntax so that it works correctly (hint: another method we have already covered might come in handy here!)." + "我们已经定义了一个 copyMachine 函数,它接受 arr(一个数组)和 num(一个数字)作为输入参数。该函数应该返回一个由 numarr 的副本组成的新数组。我们已经为您写好了大部分的代码,但它还不能正确地工作。请修改这个函数,使用展开语法,使该函数正确工作(提示:我们已经学到过的一个方法很适合用在这里!)" ], "tests": [ { - "text": "copyMachine([true, false, true], 2) should return [[true, false, true], [true, false, true]]", - "testString": "assert.deepEqual(copyMachine([true, false, true], 2), [[true, false, true], [true, false, true]], 'copyMachine([true, false, true], 2) should return [[true, false, true], [true, false, true]]');" + "text": "copyMachine([true, false, true], 2) 应该返回 [[true, false, true], [true, false, true]]。", + "testString": "assert.deepEqual(copyMachine([true, false, true], 2), [[true, false, true], [true, false, true]], 'copyMachine([true, false, true], 2) 应该返回 [[true, false, true], [true, false, true]]。');" }, { - "text": "copyMachine([1, 2, 3], 5) should return [[1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3]]", - "testString": "assert.deepEqual(copyMachine([1, 2, 3], 5), [[1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3]], 'copyMachine([1, 2, 3], 5) should return [[1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3]]');" + "text": "copyMachine([1, 2, 3], 5) 应该返回 [[1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3]]。", + "testString": "assert.deepEqual(copyMachine([1, 2, 3], 5), [[1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3]], 'copyMachine([1, 2, 3], 5) 应该返回 [[1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3]]。');" }, { - "text": "copyMachine([true, true, null], 1) should return [[true, true, null]]", - "testString": "assert.deepEqual(copyMachine([true, true, null], 1), [[true, true, null]], 'copyMachine([true, true, null], 1) should return [[true, true, null]]');" + "text": "copyMachine([true, true, null], 1) 应该返回 [[true, true, null]]。", + "testString": "assert.deepEqual(copyMachine([true, true, null], 1), [[true, true, null]], 'copyMachine([true, true, null], 1) 应该返回 [[true, true, null]]。');" }, { - "text": "copyMachine([\"it works\"], 3) should return [[\"it works\"], [\"it works\"], [\"it works\"]]", - "testString": "assert.deepEqual(copyMachine(['it works'], 3), [['it works'], ['it works'], ['it works']], 'copyMachine([\"it works\"], 3) should return [[\"it works\"], [\"it works\"], [\"it works\"]]');" + "text": "copyMachine([\"it works\"], 3) 应该返回 [[\"it works\"], [\"it works\"], [\"it works\"]]。", + "testString": "assert.deepEqual(copyMachine(['it works'], 3), [['it works'], ['it works'], ['it works']], 'copyMachine([\"it works\"], 3) 应该返回 [[\"it works\"], [\"it works\"], [\"it works\"]]。');" }, { - "text": "The copyMachine function should utilize the spread operator with array arr", - "testString": "assert.notStrictEqual(copyMachine.toString().indexOf('.concat(_toConsumableArray(arr))'), -1, 'The copyMachine function should utilize the spread operator with array arr');" + "text": "copyMachine 函数中应该对数组 arr 使用 spread operator。", + "testString": "assert.notStrictEqual(copyMachine.toString().indexOf('.concat(_toConsumableArray(arr))'), -1, 'copyMachine 函数中应该对数组 arr 使用 spread operator。');" } ], "releasedOn": "Feb 17, 2017", @@ -411,20 +411,20 @@ "id": "587d7b7b367417b2b2512b17", "title": "Combine Arrays with the Spread Operator", "description": [ - "Another huge advantage of the spread operator, is the ability to combine arrays, or to insert all the elements of one array into another, at any index. With more traditional syntaxes, we can concatenate arrays, but this only allows us to combine arrays at the end of one, and at the start of another. Spread syntax makes the following operation extremely simple:", - "
let thisArray = ['sage', 'rosemary', 'parsley', 'thyme'];

let thatArray = ['basil', 'cilantro', ...thisArray, 'coriander'];
// thatArray now equals ['basil', 'cilantro', 'sage', 'rosemary', 'parsley', 'thyme', 'coriander']
", - "Using spread syntax, we have just achieved an operation that would have been more more complex and more verbose had we used traditional methods.", + "展开运算符 的另一个大用处是合并数组,或者将某个数组的所有元素插入到另一个数组的任意位置。用传统的语法我们也可以连接两个数组,但只能两个数组首尾相接。而展开语法能使下面的操作变得极其简单:", + "
let thisArray = ['sage', 'rosemary', 'parsley', 'thyme'];

let thatArray = ['basil', 'cilantro', ...thisArray, 'coriander'];
// thatArray 现在等于 ['basil', 'cilantro', 'sage', 'rosemary', 'parsley', 'thyme', 'coriander']
", + "使用展开语法,我们这样就实现了一个用传统方法要写得很复杂冗长的操作。", "
", - "We have defined a function spreadOut that returns the variable sentence, modify the function using the spread operator so that it returns the array ['learning', 'to', 'code', 'is', 'fun']." + "我们已经定义了一个返回 sentence 变量的 spreadOut 函数,请修改该函数,利用 展开运算符 使该函数返回数组 ['learning', 'to', 'code', 'is', 'fun']。" ], "tests": [ { - "text": "spreadOut should return [\"learning\", \"to\", \"code\", \"is\", \"fun\"]", - "testString": "assert.deepEqual(spreadOut(), ['learning', 'to', 'code', 'is', 'fun'], 'spreadOut should return [\"learning\", \"to\", \"code\", \"is\", \"fun\"]');" + "text": "spreadOut 应该返回 [\"learning\", \"to\", \"code\", \"is\", \"fun\"]。", + "testString": "assert.deepEqual(spreadOut(), ['learning', 'to', 'code', 'is', 'fun'], 'spreadOut 应该返回 [\"learning\", \"to\", \"code\", \"is\", \"fun\"]。');" }, { - "text": "The spreadOut function should utilize spread syntax", - "testString": "assert.notStrictEqual(spreadOut.toString().search(/[...]/), -1, 'The spreadOut function should utilize spread syntax');" + "text": "spreadOut 函数里应该用到展开语法。", + "testString": "assert.notStrictEqual(spreadOut.toString().search(/[...]/), -1, 'spreadOut 函数里应该用到展开语法。');" } ], "releasedOn": "Feb 17, 2017", @@ -454,32 +454,32 @@ "id": "587d7b7b367417b2b2512b14", "title": "Check For The Presence of an Element With indexOf()", "description": [ - "Since arrays can be changed, or mutated, at any time, there's no guarantee about where a particular piece of data will be on a given array, or if that element even still exists. Luckily, JavaScript provides us with another built-in method, indexOf(), that allows us to quickly and easily check for the presence of an element on an array. indexOf() takes an element as a parameter, and when called, it returns the position, or index, of that element, or -1 if the element does not exist on the array.", - "For example:", - "
let fruits = ['apples', 'pears', 'oranges', 'peaches', 'pears'];

fruits.indexOf('dates') // returns -1
fruits.indexOf('oranges') // returns 2
fruits.indexOf('pears') // returns 1, the first index at which the element exists
", + "由于数组可以在任意时间被修改或者说 被改变(mutated),我们不能保证某个数据在一个给定数组中的位置,甚至不能保证该元素还存在于该数组中。幸运的是,JavaScript 给我们提供了另一个内置方法 indexOf()。这个方法让我们可以便捷地检查某个元素是否存在于一个数组中。indexOf() 方法接受一个元素作为输入参数,并返回该元素在数组中的位置(索引);若该元素不存在于数组中则返回 -1。", + "例如:", + "
let fruits = ['apples', 'pears', 'oranges', 'peaches', 'pears'];

fruits.indexOf('dates') // 返回 -1
fruits.indexOf('oranges') // 返回 2
fruits.indexOf('pears') // 返回 1,该元素在数组中的第一个索引
", "
", - "indexOf() can be incredibly useful for quickly checking for the presence of an element on an array. We have defined a function, quickCheck, that takes an array and an element as arguments. Modify the function using indexOf() so that it returns true if the passed element exists on the array, and false if it does not." + "indexOf() 在快速检查一个数组中是否有某个元素时非常有用。我们已经定义了一个 quickCheck 函数,它接受一个数组和一个元素作为输入参数。请修改这个函数,利用 indexOf() 方法,使得当输入的数组中含有输入的元素时,函数返回 true;不含有输入的元素时,函数返回 false。" ], "tests": [ { - "text": "quickCheck([\"squash\", \"onions\", \"shallots\"], \"mushrooms\") should return false", - "testString": "assert.strictEqual(quickCheck(['squash', 'onions', 'shallots'], 'mushrooms'), false, 'quickCheck([\"squash\", \"onions\", \"shallots\"], \"mushrooms\") should return false');" + "text": "quickCheck([\"squash\", \"onions\", \"shallots\"], \"mushrooms\") 应该返回 false。", + "testString": "assert.strictEqual(quickCheck(['squash', 'onions', 'shallots'], 'mushrooms'), false, 'quickCheck([\"squash\", \"onions\", \"shallots\"], \"mushrooms\") 应该返回 false。');" }, { - "text": "quickCheck([\"squash\", \"onions\", \"shallots\"], \"onions\") should return true", - "testString": "assert.strictEqual(quickCheck(['squash', 'onions', 'shallots'], 'onions'), true, 'quickCheck([\"squash\", \"onions\", \"shallots\"], \"onions\") should return true');" + "text": "quickCheck([\"squash\", \"onions\", \"shallots\"], \"onions\") 应该返回 true。", + "testString": "assert.strictEqual(quickCheck(['squash', 'onions', 'shallots'], 'onions'), true, 'quickCheck([\"squash\", \"onions\", \"shallots\"], \"onions\") 应该返回 true。');" }, { - "text": "quickCheck([3, 5, 9, 125, 45, 2], 125) should return true", - "testString": "assert.strictEqual(quickCheck([3, 5, 9, 125, 45, 2], 125), true, 'quickCheck([3, 5, 9, 125, 45, 2], 125) should return true');" + "text": "quickCheck([3, 5, 9, 125, 45, 2], 125) 应该返回 true。", + "testString": "assert.strictEqual(quickCheck([3, 5, 9, 125, 45, 2], 125), true, 'quickCheck([3, 5, 9, 125, 45, 2], 125) 应该返回 true。');" }, { - "text": "quickCheck([true, false, false], undefined) should return false", - "testString": "assert.strictEqual(quickCheck([true, false, false], undefined), false, 'quickCheck([true, false, false], undefined) should return false');" + "text": "quickCheck([true, false, false], undefined) 应该返回 false。", + "testString": "assert.strictEqual(quickCheck([true, false, false], undefined), false, 'quickCheck([true, false, false], undefined) 应该返回 false。');" }, { - "text": "The quickCheck function should utilize the indexOf() method", - "testString": "assert.notStrictEqual(quickCheck.toString().search(/\\.indexOf\\(/), -1, 'The quickCheck function should utilize the indexOf() method');" + "text": "quickCheck 函数中应该用到 indexOf() 方法。", + "testString": "assert.notStrictEqual(quickCheck.toString().search(/\\.indexOf\\(/), -1, 'quickCheck 函数中应该用到 indexOf() 方法。');" } ], "releasedOn": "Feb 17, 2017", @@ -518,20 +518,20 @@ ], "tests": [ { - "text": "filteredArray([[10, 8, 3], [14, 6, 23], [3, 18, 6]], 18) should return [ [10, 8, 3], [14, 6, 23] ]", - "testString": "assert.deepEqual(filteredArray([ [10, 8, 3], [14, 6, 23], [3, 18, 6] ], 18), [[10, 8, 3], [14, 6, 23]], 'filteredArray([[10, 8, 3], [14, 6, 23], [3, 18, 6]], 18) should return [ [10, 8, 3], [14, 6, 23] ]');" + "text": "filteredArray([[10, 8, 3], [14, 6, 23], [3, 18, 6]], 18) 应该返回 [ [10, 8, 3], [14, 6, 23] ]", + "testString": "assert.deepEqual(filteredArray([ [10, 8, 3], [14, 6, 23], [3, 18, 6] ], 18), [[10, 8, 3], [14, 6, 23]], 'filteredArray([[10, 8, 3], [14, 6, 23], [3, 18, 6]], 18) 应该返回 [ [10, 8, 3], [14, 6, 23] ]');" }, { - "text": "filteredArray([ [\"trumpets\", 2], [\"flutes\", 4], [\"saxophones\", 2] ], 2) should return [ [\"flutes\", 4] ]", - "testString": "assert.deepEqual(filteredArray([ ['trumpets', 2], ['flutes', 4], ['saxophones', 2] ], 2), [['flutes', 4]], 'filteredArray([ [\"trumpets\", 2], [\"flutes\", 4], [\"saxophones\", 2] ], 2) should return [ [\"flutes\", 4] ]');" + "text": "filteredArray([ [\"trumpets\", 2], [\"flutes\", 4], [\"saxophones\", 2] ], 2) 应该返回 [ [\"flutes\", 4] ]", + "testString": "assert.deepEqual(filteredArray([ ['trumpets', 2], ['flutes', 4], ['saxophones', 2] ], 2), [['flutes', 4]], 'filteredArray([ [\"trumpets\", 2], [\"flutes\", 4], [\"saxophones\", 2] ], 2) 应该返回 [ [\"flutes\", 4] ]');" }, { - "text": "filteredArray([ [\"amy\", \"beth\", \"sam\"], [\"dave\", \"sean\", \"peter\"] ], \"peter\") should return [ [\"amy\", \"beth\", \"sam\"] ]", - "testString": "assert.deepEqual(filteredArray([['amy', 'beth', 'sam'], ['dave', 'sean', 'peter']], 'peter'), [['amy', 'beth', 'sam']], 'filteredArray([ [\"amy\", \"beth\", \"sam\"], [\"dave\", \"sean\", \"peter\"] ], \"peter\") should return [ [\"amy\", \"beth\", \"sam\"] ]');" + "text": "filteredArray([ [\"amy\", \"beth\", \"sam\"], [\"dave\", \"sean\", \"peter\"] ], \"peter\") 应该返回 [ [\"amy\", \"beth\", \"sam\"] ]", + "testString": "assert.deepEqual(filteredArray([['amy', 'beth', 'sam'], ['dave', 'sean', 'peter']], 'peter'), [['amy', 'beth', 'sam']], 'filteredArray([ [\"amy\", \"beth\", \"sam\"], [\"dave\", \"sean\", \"peter\"] ], \"peter\") 应该返回 [ [\"amy\", \"beth\", \"sam\"] ]');" }, { - "text": "filteredArray([[3, 2, 3], [1, 6, 3], [3, 13, 26], [19, 3, 9]], 3) should return [ ]", - "testString": "assert.deepEqual(filteredArray([[3, 2, 3], [1, 6, 3], [3, 13, 26], [19, 3, 9]], 3), [], 'filteredArray([[3, 2, 3], [1, 6, 3], [3, 13, 26], [19, 3, 9]], 3) should return [ ]');" + "text": "filteredArray([[3, 2, 3], [1, 6, 3], [3, 13, 26], [19, 3, 9]], 3) 应该返回 [ ]", + "testString": "assert.deepEqual(filteredArray([[3, 2, 3], [1, 6, 3], [3, 13, 26], [19, 3, 9]], 3), [], 'filteredArray([[3, 2, 3], [1, 6, 3], [3, 13, 26], [19, 3, 9]], 3) 应该返回 [ ]');" }, { "text": "The filteredArray function should utilize a for loop", @@ -567,7 +567,7 @@ "id": "587d7b7b367417b2b2512b16", "title": "Create complex multi-dimensional arrays", "description": [ - "Awesome! You have just learned a ton about arrays! This has been a fairly high level overview, and there is plenty more to learn about working with arrays, much of which you will see in later sections. But before moving on to looking at Objects, lets take one more look, and see how arrays can become a bit more complex than what we have seen in previous challenges.", + "很好!您已经学到很多关于数组的知识了!但这些只是一个大概,您还有很多关于数组的东西要学,您将在接下来的小节中看到很多这些新知识。但在您继续去学习对象Objects)之前,让我们再花一点时间看一看,数组怎样能够变得比之前的挑战中更复杂一点。", "One of the most powerful features when thinking of arrays as data structures, is that arrays can contain, or even be completely made up of other arrays. We have seen arrays that contain arrays in previous challenges, but fairly simple ones. However, arrays can contain an infinite depth of arrays that can contain other arrays, each with their own arbitrary levels of depth, and so on. In this way, an array can very quickly become very complex data structure, known as a multi-dimensional, or nested array. Consider the following example:", "
let nestedArray = [ // top, or first level - the outer most array
  ['deep'], // an array within an array, 2 levels of depth
  [
    ['deeper'], ['deeper'] // 2 arrays nested 3 levels deep
  ],
  [
    [
      ['deepest'], ['deepest'] // 2 arrays nested 4 levels deep
    ],
    [
      [
        ['deepest-est?'] // an array nested 5 levels deep
      ]
    ]
  ]
];
", "While this example may seem convoluted, this level of complexity is not unheard of, or even unusual, when dealing with large amounts of data.", @@ -763,16 +763,16 @@ "testString": "assert.deepEqual(foods, {apples: 25, oranges: 32, plums: 28, bananas: 13, grapes: 35, strawberries: 27}, 'The foods object should have only the following key-value pairs: apples: 25, oranges: 32, plums: 28, bananas: 13, grapes: 35, strawberries: 27');" }, { - "text": "checkInventory(\"apples\") should return 25", - "testString": "assert.strictEqual(checkInventory('apples'), 25, 'checkInventory(\"apples\") should return 25');" + "text": "checkInventory(\"apples\") 应该返回 25", + "testString": "assert.strictEqual(checkInventory('apples'), 25, 'checkInventory(\"apples\") 应该返回 25');" }, { - "text": "checkInventory(\"bananas\") should return 13", - "testString": "assert.strictEqual(checkInventory('bananas'), 13, 'checkInventory(\"bananas\") should return 13');" + "text": "checkInventory(\"bananas\") 应该返回 13", + "testString": "assert.strictEqual(checkInventory('bananas'), 13, 'checkInventory(\"bananas\") 应该返回 13');" }, { - "text": "checkInventory(\"strawberries\") should return 27", - "testString": "assert.strictEqual(checkInventory('strawberries'), 27, 'checkInventory(\"strawberries\") should return 27');" + "text": "checkInventory(\"strawberries\") 应该返回 27", + "testString": "assert.strictEqual(checkInventory('strawberries'), 27, 'checkInventory(\"strawberries\") 应该返回 27');" } ], "releasedOn": "Feb 17, 2017", @@ -925,21 +925,21 @@ "id": "587d7b7d367417b2b2512b1d", "title": " Iterate Through the Keys of an Object with a for...in Statement", "description": [ - "Sometimes you may need to iterate through all the keys within an object. This requires a specific syntax in JavaScript called a for...in statement. For our users object, this could look like:", + "有时候你会需要遍历一个对象中的所有键。这需要 JavaScript 中的一个特殊语法:for...in 语句。以遍历 users 对象的键为例:", "
for (let user in users) {
  console.log(user);
};

// logs:
Alan
Jeff
Sarah
Ryan
", - "In this statement, we defined a variable user, and as you can see, this variable was reset during each iteration to each of the object's keys as the statement looped through the object, resulting in each user's name being printed to the console.", - "NOTE:
Objects do not maintain an ordering to stored keys like arrays do; thus a keys position on an object, or the relative order in which it appears, is irrelevant when referencing or accessing that key.", + "在这个语句中,我们定义了一个 user 变量,您可以看到,这个变量在 for...in 语句对对象的每一个键的遍历中都会被重置。", + "注意:
跟数组不同,对象不会维持其中的键的顺序,因此一个对象中某个键的位置,或者说它出现的相对顺序,在引用或访问该键时是不确定的。", "
", - "We've defined a function, countOnline; use a for...in statement within this function to loop through the users in the users object and return the number of users whose online property is set to true." + "我们已经定义了一个 countOnline 函数,请在其中使用一个 for...in 语句来遍历 users 对象中的用户,并返回 online 属性为 true 的用户的数量。" ], "tests": [ { - "text": "The users object contains users Jeff and Ryan with online set to true and users Alan and Sarah with online set to false", - "testString": "assert(users.Alan.online === false && users.Jeff.online === true && users.Sarah.online === false && users.Ryan.online === true, 'The users object contains users Jeff and Ryan with online set to true and users Alan and Sarah with online set to false');" + "text": "users 对象中应该包含 onlinetrue 的用户对象 JeffRyan 以及 onlinefalse 的用户对象 AlanSarah。", + "testString": "assert(users.Alan.online === false && users.Jeff.online === true && users.Sarah.online === false && users.Ryan.online === true, 'users 对象中应该包含 onlinetrue 的用户对象 JeffRyan 以及 onlinefalse 的用户对象 AlanSarah。');" }, { - "text": "The function countOnline returns the number of users with the online property set to true", - "testString": "assert((function() { users.Harry = {online: true}; users.Sam = {online: true}; users.Carl = {online: true}; return countOnline(users) })() === 5, 'The function countOnline returns the number of users with the online property set to true');" + "text": "countOnline 函数应该返回 online 属性为 true 的用户的数量。", + "testString": "assert((function() { users.Harry = {online: true}; users.Sam = {online: true}; users.Carl = {online: true}; return countOnline(users) })() === 5, 'countOnline 函数应该返回 online 属性为 true 的用户的数量。');" } ], "releasedOn": "Feb 17, 2017", @@ -987,18 +987,18 @@ "id": "587d7b7d367417b2b2512b1e", "title": "Generate an Array of All Object Keys with Object.keys()", "description": [ - "We can also generate an array which contains all the keys stored in an object using the Object.keys() method and passing in an object as the argument. This will return an array with strings representing each property in the object. Again, there will be no specific order to the entries in the array.", + "我们还可以输入一个对象作为参数来调用 Object.keys() 方法,使其生成一个包含对象中所有键的数组。这会返回一个由对象中所有键的名称(字符串)组成的数组。再次说明,这个数组中的项的顺序是不确定的。", "
", - "Finish writing the getArrayOfUsers function so that it returns an array containing all the properties in the object it receives as an argument." + "请您完成 getArrayOfUsers 函数,使其返回一个包含输入的对象的所有属性的数组。" ], "tests": [ { - "text": "The users object only contains the keys Alan, Jeff, Sarah, and Ryan", - "testString": "assert('Alan' in users && 'Jeff' in users && 'Sarah' in users && 'Ryan' in users && Object.keys(users).length === 4, 'The users object only contains the keys Alan, Jeff, Sarah, and Ryan');" + "text": "users 对象应该只包含 AlanJeffSarahRyan 这 4 个键", + "testString": "assert('Alan' in users && 'Jeff' in users && 'Sarah' in users && 'Ryan' in users && Object.keys(users).length === 4, 'users 对象应该只包含 AlanJeffSarahRyan 这 4 个键。');" }, { - "text": "The getArrayOfUsers function returns an array which contains all the keys in the users object", - "testString": "assert((function() { users.Sam = {}; users.Lewis = {}; let R = getArrayOfUsers(users); return (R.indexOf('Alan') !== -1 && R.indexOf('Jeff') !== -1 && R.indexOf('Sarah') !== -1 && R.indexOf('Ryan') !== -1 && R.indexOf('Sam') !== -1 && R.indexOf('Lewis') !== -1); })() === true, 'The getArrayOfUsers function returns an array which contains all the keys in the users object');" + "text": "getArrayOfUsers 函数应该返回一个包含 users 对象中所有键的数组", + "testString": "assert((function() { users.Sam = {}; users.Lewis = {}; let R = getArrayOfUsers(users); return (R.indexOf('Alan') !== -1 && R.indexOf('Jeff') !== -1 && R.indexOf('Sarah') !== -1 && R.indexOf('Ryan') !== -1 && R.indexOf('Sam') !== -1 && R.indexOf('Lewis') !== -1); })() === true, 'getArrayOfUsers 函数应该返回一个包含 users 对象中所有键的数组。');" } ], "releasedOn": "Feb 17, 2017", @@ -1046,22 +1046,22 @@ "id": "587d7b7d367417b2b2512b1f", "title": "Modify an Array Stored in an Object", "description": [ - "Now you've seen all the basic operations for JavaScript objects. You can add, modify, and remove key-value pairs, check if keys exist, and iterate over all the keys in an object. As you continue learning JavaScript you will see even more versatile applications of objects. Additionally, the optional Advanced Data Structures lessons later in the curriculum also cover the ES6 Map and Set objects, both of which are similar to ordinary objects but provide some additional features. Now that you've learned the basics of arrays and objects, you're fully prepared to begin tackling more complex problems using JavaScript!", + "现在您已经接触到 JavaScript 对象的所有运算。您可以增加、修改和移除键值对,检查某个键是否存在,并且遍历一个对象中的所有键。在您继续学习 JavaScript 的过程中,您会看到更多种多样的对对象的应用。另外,后续的《高级数据结构》课程还会介绍 ES6 的 MapSet 对象。这两种对象都跟一般的对象相似,但它们提供了一些额外的特性。现在您已经学到了数组和对象的基础知识,您已经可以继续用 JavaScript 来解决更加复杂的问题了!", "
", - "Take a look at the object we've provided in the code editor. The user object contains three keys. The data key contains five keys, one of which contains an array of friends. From this, you can see how flexible objects are as data structures. We've started writing a function addFriend. Finish writing it so that it takes a user object and adds the name of the friend argument to the array stored in user.data.friends and returns that array." + "请您看一下代码编辑器中我们提供的对象。user 对象包含 3 个键。data 对象包含 5 个键,其中一个包含一个 friends 数组。从这个例子您可以看到对象作为数据结构是多么的灵活。我们已经写了 addFriend 函数的一部分,请您完成这个函数,使其接受一个 user 对象,将 friend 参数中的名字添加到 user.data.friends 数组中并返回该数组。" ], "tests": [ { - "text": "The user object has name, age, and data keys", - "testString": "assert('name' in user && 'age' in user && 'data' in user, 'The user object has name, age, and data keys');" + "text": "user 对象应该包含 nameagedata 三个键。", + "testString": "assert('name' in user && 'age' in user && 'data' in user, 'user 对象应该包含 nameagedata 三个键。');" }, { - "text": "The addFriend function accepts a user object and a friend string as arguments and adds the friend to the array of friends in the user object", - "testString": "assert((function() { let L1 = user.data.friends.length; addFriend(user, 'Sean'); let L2 = user.data.friends.length; return (L2 === L1 + 1); })(), 'The addFriend function accepts a user object and a friend string as arguments and adds the friend to the array of friends in the user object');" + "text": "addFriend 函数应该接受一个 user 对象和一个 friend 字符串作为输入参数,并将 friend 插入到 user 对象的 friends 数组中。", + "testString": "assert((function() { let L1 = user.data.friends.length; addFriend(user, 'Sean'); let L2 = user.data.friends.length; return (L2 === L1 + 1); })(), 'addFriend 函数应该接受一个 user 对象和一个 friend 字符串作为输入参数,并将 friend 插入到 user 对象的 friends 数组中。');" }, { - "text": "addFriend(user, \"Pete\") should return [\"Sam\", \"Kira\", \"Tomo\", \"Pete\"]", - "testString": "assert.deepEqual((function() { delete user.data.friends; user.data.friends = ['Sam', 'Kira', 'Tomo']; return addFriend(user, 'Pete') })(), ['Sam', 'Kira', 'Tomo', 'Pete'], 'addFriend(user, \"Pete\") should return [\"Sam\", \"Kira\", \"Tomo\", \"Pete\"]');" + "text": "addFriend(user, \"Pete\") 应该返回 [\"Sam\", \"Kira\", \"Tomo\", \"Pete\"]。", + "testString": "assert.deepEqual((function() { delete user.data.friends; user.data.friends = ['Sam', 'Kira', 'Tomo']; return addFriend(user, 'Pete') })(), ['Sam', 'Kira', 'Tomo', 'Pete'], 'addFriend(user, \"Pete\") 应该返回 [\"Sam\", \"Kira\", \"Tomo\", \"Pete\"]。');" } ], "releasedOn": "Feb 17, 2017", @@ -1107,4 +1107,4 @@ } } ] -} \ No newline at end of file +} diff --git a/02-javascript-algorithms-and-data-structures/basic-javascript.json b/02-javascript-algorithms-and-data-structures/basic-javascript.json index 41de1c6..6a95a1b 100644 --- a/02-javascript-algorithms-and-data-structures/basic-javascript.json +++ b/02-javascript-algorithms-and-data-structures/basic-javascript.json @@ -8,27 +8,27 @@ "id": "bd7123c9c441eddfaeb4bdef", "title": "Comment Your JavaScript Code", "description": [ - "Comments are lines of code that JavaScript will intentionally ignore. Comments are a great way to leave notes to yourself and to other people who will later need to figure out what that code does.", - "There are two ways to write comments in JavaScript:", - "Using // will tell JavaScript to ignore the remainder of the text on the current line:", - "
// This is an in-line comment.
", - "You can make a multi-line comment beginning with /* and ending with */:", - "
/* This is a
multi-line comment */
", - "Best Practice
As you write code, you should regularly add comments to clarify the function of parts of your code. Good commenting can help communicate the intent of your code—both for others and for your future self.", + "注释(comment)是 JavaScript 中会被有意忽略的行。注释是给自己和以后需要了解代码作用的其他人留下笔记的一个好的方式。", + "在 JavaScript 有两种方式写注释:", + "用 // 告诉 JavaScript 忽略当前行在该符号之后的文本:", + "
// 这是一个行内注释。
", + "您可以以 /* 开始并以 */ 结束来写多行注释:", + "
/* 这是一个
多行注释 */
", + "最佳实践
在您编码时,您应该定期添加一些注释来阐明您的某些代码的作用。好的注释能够让别人和未来的您自己了解您的代码。", "
", - "Try creating one of each type of comment." + "请尝试写一下两种注释。" ], "solutions": [ "// Fake Comment\n/* Another Comment */" ], "tests": [ { - "text": "Create a // style comment that contains at least five letters.", - "testString": "assert(code.match(/(\\/\\/)...../g), 'Create a // style comment that contains at least five letters.');" + "text": "请写一个 // 方式的注释,并包含至少 5 个字符。", + "testString": "assert(code.match(/(\\/\\/)...../g), '请写一个 // 方式的注释,并包含至少 5 个字符。');" }, { - "text": "Create a /* */ style comment that contains at least five letters.", - "testString": "assert(code.match(/(\\/\\*)([^\\/]{5,})(?=\\*\\/)/gm), 'Create a /* */ style comment that contains at least five letters.');" + "text": "请写一个 /* */ 方式的注释,并包含至少 5 个字符。", + "testString": "assert(code.match(/(\\/\\*)([^\\/]{5,})(?=\\*\\/)/gm), '请写一个 /* */ 方式的注释,并包含至少 5 个字符。');" } ], "challengeType": 1, @@ -47,7 +47,7 @@ "id": "bd7123c9c443eddfaeb5bdef", "title": "Declare JavaScript Variables", "description": [ - "In computer science, data is anything that is meaningful to the computer. JavaScript provides seven different data types which are undefined, null, boolean, string, symbol, number, and object.", + "在计算机科学中,数据(data) 是对计算机有意义的所有东西。JavaScript 提供了 7 中不同的 数据类型(data type),分别是 undefined(未定义)、null(空值)、boolean(布尔值)、string(字符串)、symbol(符号)、number(数字)和 object(对象)。", "For example, computers distinguish between numbers, such as the number 12, and strings, such as \"12\", \"dog\", or \"123 cats\", which are collections of characters. Computers can perform mathematical operations on a number, but not on a string.", "Variables allow computers to store and manipulate data in a dynamic fashion. They do this by using a \"label\" to point to the data rather than using the data itself. Any of the seven data types may be stored in a variable.", "Variables are similar to the x and y variables you use in mathematics, which means they're a simple name to represent the data we want to refer to. Computer variables differ from mathematical variables in that they can store different values at different times.", @@ -330,8 +330,8 @@ ], "tests": [ { - "text": "sum should equal 20", - "testString": "assert(sum === 20, 'sum should equal 20');" + "text": "sum 应该等于 20", + "testString": "assert(sum === 20, 'sum 应该等于 20');" }, { "text": "Use the + operator", @@ -506,8 +506,8 @@ ], "tests": [ { - "text": "myVar should equal 88", - "testString": "assert(myVar === 88, 'myVar should equal 88');" + "text": "myVar 应该等于 88", + "testString": "assert(myVar === 88, 'myVar 应该等于 88');" }, { "text": "myVar = myVar + 1; should be changed", @@ -560,8 +560,8 @@ ], "tests": [ { - "text": "myVar should equal 10", - "testString": "assert(myVar === 10, 'myVar should equal 10');" + "text": "myVar 应该等于 10", + "testString": "assert(myVar === 10, 'myVar 应该等于 10');" }, { "text": "myVar = myVar - 1; should be changed", @@ -610,12 +610,12 @@ ], "tests": [ { - "text": "myDecimal should be a number.", - "testString": "assert(typeof myDecimal === \"number\", 'myDecimal should be a number.');" + "text": "myDecimal 应该是一个数字。", + "testString": "assert(typeof myDecimal === \"number\", 'myDecimal 应该是一个数字。');" }, { - "text": "myDecimal should have a decimal point", - "testString": "assert(myDecimal % 1 != 0, 'myDecimal should have a decimal point'); " + "text": "myDecimal 应该含有一个小数点。", + "testString": "assert(myDecimal % 1 != 0, 'myDecimal 应该含有一个小数点。'); " } ], "challengeType": 1, @@ -652,8 +652,8 @@ ], "tests": [ { - "text": "The variable product should equal 5.0.", - "testString": "assert(product === 5.0, 'The variable product should equal 5.0.');" + "text": "变量 product 应该等于 5.0.", + "testString": "assert(product === 5.0, '变量 product 应该等于 5.0.');" }, { "text": "You should use the * operator", @@ -689,8 +689,8 @@ "solutions": [], "tests": [ { - "text": "The variable quotient should equal 2.2", - "testString": "assert(quotient === 2.2, 'The variable quotient should equal 2.2');" + "text": "变量 quotient 应该等于 2.2", + "testString": "assert(quotient === 2.2, '变量 quotient 应该等于 2.2');" }, { "text": "You should use the / operator to divide 4.4 by 2", @@ -738,8 +738,8 @@ ], "tests": [ { - "text": "The variable remainder should be initialized", - "testString": "assert(/var\\s+?remainder/.test(code), 'The variable remainder should be initialized');" + "text": "变量 remainder should be initialized", + "testString": "assert(/var\\s+?remainder/.test(code), '变量 remainder should be initialized');" }, { "text": "The value of remainder should be 2", @@ -787,16 +787,16 @@ ], "tests": [ { - "text": "a should equal 15", - "testString": "assert(a === 15, 'a should equal 15');" + "text": "a 应该等于 15", + "testString": "assert(a === 15, 'a 应该等于 15');" }, { - "text": "b should equal 26", - "testString": "assert(b === 26, 'b should equal 26');" + "text": "b 应该等于 26", + "testString": "assert(b === 26, 'b 应该等于 26');" }, { - "text": "c should equal 19", - "testString": "assert(c === 19, 'c should equal 19');" + "text": "c 应该等于 19", + "testString": "assert(c === 19, 'c 应该等于 19');" }, { "text": "You should use the += operator for each variable", @@ -849,16 +849,16 @@ ], "tests": [ { - "text": "a should equal 5", - "testString": "assert(a === 5, 'a should equal 5');" + "text": "a 应该等于 5", + "testString": "assert(a === 5, 'a 应该等于 5');" }, { - "text": "b should equal -6", - "testString": "assert(b === -6, 'b should equal -6');" + "text": "b 应该等于 -6", + "testString": "assert(b === -6, 'b 应该等于 -6');" }, { - "text": "c should equal 2", - "testString": "assert(c === 2, 'c should equal 2');" + "text": "c 应该等于 2", + "testString": "assert(c === 2, 'c 应该等于 2');" }, { "text": "You should use the -= operator for each variable", @@ -912,16 +912,16 @@ ], "tests": [ { - "text": "a should equal 25", - "testString": "assert(a === 25, 'a should equal 25');" + "text": "a 应该等于 25", + "testString": "assert(a === 25, 'a 应该等于 25');" }, { - "text": "b should equal 36", - "testString": "assert(b === 36, 'b should equal 36');" + "text": "b 应该等于 36", + "testString": "assert(b === 36, 'b 应该等于 36');" }, { - "text": "c should equal 46", - "testString": "assert(c === 46, 'c should equal 46');" + "text": "c 应该等于 46", + "testString": "assert(c === 46, 'c 应该等于 46');" }, { "text": "You should use the *= operator for each variable", @@ -975,16 +975,16 @@ ], "tests": [ { - "text": "a should equal 4", - "testString": "assert(a === 4, 'a should equal 4');" + "text": "a 应该等于 4", + "testString": "assert(a === 4, 'a 应该等于 4');" }, { - "text": "b should equal 27", - "testString": "assert(b === 27, 'b should equal 27');" + "text": "b 应该等于 27", + "testString": "assert(b === 27, 'b 应该等于 27');" }, { - "text": "c should equal 3", - "testString": "assert(c === 3, 'c should equal 3');" + "text": "c 应该等于 3", + "testString": "assert(c === 3, 'c 应该等于 3');" }, { "text": "You should use the /= operator for each variable", @@ -1035,12 +1035,12 @@ ], "tests": [ { - "text": "myFirstName 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;}})(), 'myFirstName should be a string with at least one character in it.');" + "text": "myFirstName 应该是一个含有至少一个字符的字符串。", + "testString": "assert((function(){if(typeof myFirstName !== \"undefined\" && typeof myFirstName === \"string\" && myFirstName.length > 0){return true;}else{return false;}})(), 'myFirstName 应该是一个含有至少一个字符的字符串。');" }, { - "text": "myLastName 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;}})(), 'myLastName should be a string with at least one character in it.');" + "text": "myLastName 应该是一个含有至少一个字符的字符串。", + "testString": "assert((function(){if(typeof myLastName !== \"undefined\" && typeof myLastName === \"string\" && myLastName.length > 0){return true;}else{return false;}})(), 'myLastName 应该是一个含有至少一个字符的字符串。');" } ], "challengeType": 1, @@ -1784,8 +1784,8 @@ ], "tests": [ { - "text": "wordBlanks(\"\",\"\",\"\",\"\") should return a string.", - "testString": "assert(typeof wordBlanks(\"\",\"\",\"\",\"\") === 'string', 'wordBlanks(\"\",\"\",\"\",\"\") should return a string.');" + "text": "wordBlanks(\"\",\"\",\"\",\"\") 应该返回一个字符串。", + "testString": "assert(typeof wordBlanks(\"\",\"\",\"\",\"\") === 'string', 'wordBlanks(\"\",\"\",\"\",\"\") 应该返回一个字符串。');" }, { "text": "wordBlanks(\"dog\", \"big\", \"ran\", \"quickly\") should contain all of the passed in words separated by non-word characters (and any additional words in your madlib).", @@ -1926,8 +1926,8 @@ ], "tests": [ { - "text": "The variable myData should equal the first value of myArray.", - "testString": "assert((function(){if(typeof myArray !== 'undefined' && typeof myData !== 'undefined' && myArray[0] === myData){return true;}else{return false;}})(), 'The variable myData should equal the first value of myArray.');" + "text": "变量 myData 应该等于 the first value of myArray.", + "testString": "assert((function(){if(typeof myArray !== 'undefined' && typeof myData !== 'undefined' && myArray[0] === myData){return true;}else{return false;}})(), '变量 myData 应该等于 the first value of myArray.');" }, { "text": "The data in variable myArray should be accessed using bracket notation.", @@ -2265,8 +2265,8 @@ ], "tests": [ { - "text": "myList should be an array", - "testString": "assert(isArray, 'myList should be an array');" + "text": "myList 应该是一个数组。", + "testString": "assert(isArray, 'myList 应该是一个数组。');" }, { "text": "The first elements in each of your sub-arrays must all be strings", @@ -2342,8 +2342,8 @@ ], "tests": [ { - "text": "reusableFunction should be a function", - "testString": "assert(typeof reusableFunction === 'function', 'reusableFunction should be a function');" + "text": "reusableFunction 应该是一个函数。", + "testString": "assert(typeof reusableFunction === 'function', 'reusableFunction 应该是一个函数。');" }, { "text": "reusableFunction should output \"Hi World\" to the dev console", @@ -2424,8 +2424,8 @@ ], "tests": [ { - "text": "functionWithArgs should be a function", - "testString": "assert(typeof functionWithArgs === 'function', 'functionWithArgs should be a function');" + "text": "functionWithArgs 应该是一个函数。", + "testString": "assert(typeof functionWithArgs === 'function', 'functionWithArgs 应该是一个函数。');" }, { "text": "functionWithArgs(1,2) should output 3", @@ -2677,8 +2677,8 @@ "testString": "assert(outerWear === \"T-Shirt\", 'Do not change the value of the global outerWear');" }, { - "text": "myOutfit should return \"sweater\"", - "testString": "assert(myOutfit() === \"sweater\", 'myOutfit should return \"sweater\"');" + "text": "myOutfit 应该返回 \"sweater\"", + "testString": "assert(myOutfit() === \"sweater\", 'myOutfit 应该返回 \"sweater\"');" }, { "text": "Do not change the return statement", @@ -2728,20 +2728,20 @@ ], "tests": [ { - "text": "timesFive should be a function", - "testString": "assert(typeof timesFive === 'function', 'timesFive should be a function');" + "text": "timesFive 应该是一个函数。", + "testString": "assert(typeof timesFive === 'function', 'timesFive 应该是一个函数。');" }, { - "text": "timesFive(5) should return 25", - "testString": "assert(timesFive(5) === 25, 'timesFive(5) should return 25');" + "text": "timesFive(5) 应该返回 25", + "testString": "assert(timesFive(5) === 25, 'timesFive(5) 应该返回 25');" }, { - "text": "timesFive(2) should return 10", - "testString": "assert(timesFive(2) === 10, 'timesFive(2) should return 10');" + "text": "timesFive(2) 应该返回 10", + "testString": "assert(timesFive(2) === 10, 'timesFive(2) 应该返回 10');" }, { - "text": "timesFive(0) should return 0", - "testString": "assert(timesFive(0) === 0, 'timesFive(0) should return 0');" + "text": "timesFive(0) 应该返回 0", + "testString": "assert(timesFive(0) === 0, 'timesFive(0) 应该返回 0');" } ], "challengeType": 1, @@ -2784,8 +2784,8 @@ ], "tests": [ { - "text": "addFive should be a function", - "testString": "assert(typeof addFive === 'function', 'addFive should be a function');" + "text": "addFive 应该是一个函数。", + "testString": "assert(typeof addFive === 'function', 'addFive 应该是一个函数。');" }, { "text": "sum should be equal to 8", @@ -2905,24 +2905,24 @@ ], "tests": [ { - "text": "nextInLine([], 5) should return a number.", - "testString": "assert.isNumber(nextInLine([],5), 'nextInLine([], 5) should return a number.');" + "text": "nextInLine([], 5) 应该返回一个数字。", + "testString": "assert.isNumber(nextInLine([],5), 'nextInLine([], 5) 应该返回一个数字。');" }, { - "text": "nextInLine([], 1) should return 1", - "testString": "assert(nextInLine([],1) === 1, 'nextInLine([], 1) should return 1');" + "text": "nextInLine([], 1) 应该返回 1", + "testString": "assert(nextInLine([],1) === 1, 'nextInLine([], 1) 应该返回 1');" }, { - "text": "nextInLine([2], 1) should return 2", - "testString": "assert(nextInLine([2],1) === 2, 'nextInLine([2], 1) should return 2');" + "text": "nextInLine([2], 1) 应该返回 2", + "testString": "assert(nextInLine([2],1) === 2, 'nextInLine([2], 1) 应该返回 2');" }, { - "text": "nextInLine([5,6,7,8,9], 1) should return 5", - "testString": "assert(nextInLine([5,6,7,8,9],1) === 5, 'nextInLine([5,6,7,8,9], 1) should return 5');" + "text": "nextInLine([5,6,7,8,9], 1) 应该返回 5", + "testString": "assert(nextInLine([5,6,7,8,9],1) === 5, 'nextInLine([5,6,7,8,9], 1) 应该返回 5');" }, { - "text": "After nextInLine(testArr, 10), testArr[4] should be 10", - "testString": "nextInLine(testArr, 10); assert(testArr[4] === 10, 'After nextInLine(testArr, 10), testArr[4] should be 10');" + "text": "执行 nextInLine(testArr, 10) 之后,testArr[4] 应该变成 10", + "testString": "nextInLine(testArr, 10); assert(testArr[4] === 10, '执行 nextInLine(testArr, 10) 之后,testArr[4] 应该变成 10');" } ], "challengeType": 1, @@ -2980,22 +2980,22 @@ "id": "bd7123c9c441eddfaeb5bdef", "title": "Understanding Boolean Values", "description": [ - "Another data type is the Boolean. Booleans may only be one of two values: true or false. They are basically little on-off switches, where true is \"on\" and false is \"off.\" These two states are mutually exclusive.", - "Note
Boolean values are never written with quotes. The strings \"true\" and \"false\" are not Boolean and have no special meaning in JavaScript.", + "另一个数据类型是布尔值 Boolean。一个 Boolean 变量的值只能取 true 或者 false 这两个值中的一个。布尔值相当于一个小开关, true 表示“开”, false 表示“关”。这两个状态是互斥的。", + "注意
一个 Boolean 值是不写在引号中的。字符串 \"true\" and \"false\" 并不是 Boolean ,在 JavaScript 中没有特殊的意义。", "
", - "Modify the welcomeToBooleans function so that it returns true instead of false when the run button is clicked." + "请修改 welcomeToBooleans 函数,使其返回 true 而不是 false" ], "solutions": [ "function welcomeToBooleans() {\n return true; // Change this line\n}" ], "tests": [ { - "text": "The welcomeToBooleans() function should return a boolean (true/false) value.", - "testString": "assert(typeof welcomeToBooleans() === 'boolean', 'The welcomeToBooleans() function should return a boolean (true/false) value.');" + "text": "welcomeToBooleans() 函数应该返回一个布尔值( (true/false) )。", + "testString": "assert(typeof welcomeToBooleans() === 'boolean', 'The welcomeToBooleans() 函数应该返回一个布尔值( (true/false) )。');" }, { - "text": "welcomeToBooleans() should return true.", - "testString": "assert(welcomeToBooleans() === true, 'welcomeToBooleans() should return true.');" + "text": "welcomeToBooleans() 应该返回 true", + "testString": "assert(welcomeToBooleans() === true, 'welcomeToBooleans() 应该返回 true');" } ], "challengeType": 1, @@ -3040,24 +3040,24 @@ ], "tests": [ { - "text": "trueOrFalse should be a function", - "testString": "assert(typeof trueOrFalse === \"function\", 'trueOrFalse should be a function');" + "text": "trueOrFalse 应该是一个函数。", + "testString": "assert(typeof trueOrFalse === \"function\", 'trueOrFalse 应该是一个函数。');" }, { - "text": "trueOrFalse(true) should return a string", - "testString": "assert(typeof trueOrFalse(true) === \"string\", 'trueOrFalse(true) should return a string');" + "text": "trueOrFalse(true) 应该返回一个字符串", + "testString": "assert(typeof trueOrFalse(true) === \"string\", 'trueOrFalse(true) 应该返回一个字符串');" }, { - "text": "trueOrFalse(false) should return a string", - "testString": "assert(typeof trueOrFalse(false) === \"string\", 'trueOrFalse(false) should return a string');" + "text": "trueOrFalse(false) 应该返回一个字符串", + "testString": "assert(typeof trueOrFalse(false) === \"string\", 'trueOrFalse(false) 应该返回一个字符串');" }, { - "text": "trueOrFalse(true) should return \"Yes, that was true\"", - "testString": "assert(trueOrFalse(true) === \"Yes, that was true\", 'trueOrFalse(true) should return \"Yes, that was true\"');" + "text": "trueOrFalse(true) 应该返回 \"Yes, that was true\"", + "testString": "assert(trueOrFalse(true) === \"Yes, that was true\", 'trueOrFalse(true) 应该返回 \"Yes, that was true\"');" }, { - "text": "trueOrFalse(false) should return \"No, that was false\"", - "testString": "assert(trueOrFalse(false) === \"No, that was false\", 'trueOrFalse(false) should return \"No, that was false\"');" + "text": "trueOrFalse(false) 应该返回 \"No, that was false\"", + "testString": "assert(trueOrFalse(false) === \"No, that was false\", 'trueOrFalse(false) 应该返回 \"No, that was false\"');" } ], "challengeType": 1, @@ -3113,16 +3113,16 @@ ], "tests": [ { - "text": "testEqual(10) should return \"Not Equal\"", - "testString": "assert(testEqual(10) === \"Not Equal\", 'testEqual(10) should return \"Not Equal\"');" + "text": "testEqual(10) 应该返回 \"Not Equal\"", + "testString": "assert(testEqual(10) === \"Not Equal\", 'testEqual(10) 应该返回 \"Not Equal\"');" }, { - "text": "testEqual(12) should return \"Equal\"", - "testString": "assert(testEqual(12) === \"Equal\", 'testEqual(12) should return \"Equal\"');" + "text": "testEqual(12) 应该返回 \"Equal\"", + "testString": "assert(testEqual(12) === \"Equal\", 'testEqual(12) 应该返回 \"Equal\"');" }, { - "text": "testEqual(\"12\") should return \"Equal\"", - "testString": "assert(testEqual(\"12\") === \"Equal\", 'testEqual(\"12\") should return \"Equal\"');" + "text": "testEqual(\"12\") 应该返回 \"Equal\"", + "testString": "assert(testEqual(\"12\") === \"Equal\", 'testEqual(\"12\") 应该返回 \"Equal\"');" }, { "text": "You should use the == operator", @@ -3170,16 +3170,16 @@ ], "tests": [ { - "text": "testStrict(10) should return \"Not Equal\"", - "testString": "assert(testStrict(10) === \"Not Equal\", 'testStrict(10) should return \"Not Equal\"');" + "text": "testStrict(10) 应该返回 \"Not Equal\"", + "testString": "assert(testStrict(10) === \"Not Equal\", 'testStrict(10) 应该返回 \"Not Equal\"');" }, { - "text": "testStrict(7) should return \"Equal\"", - "testString": "assert(testStrict(7) === \"Equal\", 'testStrict(7) should return \"Equal\"');" + "text": "testStrict(7) 应该返回 \"Equal\"", + "testString": "assert(testStrict(7) === \"Equal\", 'testStrict(7) 应该返回 \"Equal\"');" }, { - "text": "testStrict(\"7\") should return \"Not Equal\"", - "testString": "assert(testStrict(\"7\") === \"Not Equal\", 'testStrict(\"7\") should return \"Not Equal\"');" + "text": "testStrict(\"7\") 应该返回 \"Not Equal\"", + "testString": "assert(testStrict(\"7\") === \"Not Equal\", 'testStrict(\"7\") 应该返回 \"Not Equal\"');" }, { "text": "You should use the === operator", @@ -3228,12 +3228,12 @@ ], "tests": [ { - "text": "compareEquality(10, \"10\") should return \"Not Equal\"", - "testString": "assert(compareEquality(10, \"10\") === \"Not Equal\", 'compareEquality(10, \"10\") should return \"Not Equal\"');" + "text": "compareEquality(10, \"10\") 应该返回 \"Not Equal\"", + "testString": "assert(compareEquality(10, \"10\") === \"Not Equal\", 'compareEquality(10, \"10\") 应该返回 \"Not Equal\"');" }, { - "text": "compareEquality(\"20\", 20) should return \"Not Equal\"", - "testString": "assert(compareEquality(\"20\", 20) === \"Not Equal\", 'compareEquality(\"20\", 20) should return \"Not Equal\"');" + "text": "compareEquality(\"20\", 20) 应该返回 \"Not Equal\"", + "testString": "assert(compareEquality(\"20\", 20) === \"Not Equal\", 'compareEquality(\"20\", 20) 应该返回 \"Not Equal\"');" }, { "text": "You should use the === operator", @@ -3279,24 +3279,24 @@ ], "tests": [ { - "text": "testNotEqual(99) should return \"Equal\"", - "testString": "assert(testNotEqual(99) === \"Equal\", 'testNotEqual(99) should return \"Equal\"');" + "text": "testNotEqual(99) 应该返回 \"Equal\"", + "testString": "assert(testNotEqual(99) === \"Equal\", 'testNotEqual(99) 应该返回 \"Equal\"');" }, { - "text": "testNotEqual(\"99\") should return \"Equal\"", - "testString": "assert(testNotEqual(\"99\") === \"Equal\", 'testNotEqual(\"99\") should return \"Equal\"');" + "text": "testNotEqual(\"99\") 应该返回 \"Equal\"", + "testString": "assert(testNotEqual(\"99\") === \"Equal\", 'testNotEqual(\"99\") 应该返回 \"Equal\"');" }, { - "text": "testNotEqual(12) should return \"Not Equal\"", - "testString": "assert(testNotEqual(12) === \"Not Equal\", 'testNotEqual(12) should return \"Not Equal\"');" + "text": "testNotEqual(12) 应该返回 \"Not Equal\"", + "testString": "assert(testNotEqual(12) === \"Not Equal\", 'testNotEqual(12) 应该返回 \"Not Equal\"');" }, { - "text": "testNotEqual(\"12\") should return \"Not Equal\"", - "testString": "assert(testNotEqual(\"12\") === \"Not Equal\", 'testNotEqual(\"12\") should return \"Not Equal\"');" + "text": "testNotEqual(\"12\") 应该返回 \"Not Equal\"", + "testString": "assert(testNotEqual(\"12\") === \"Not Equal\", 'testNotEqual(\"12\") 应该返回 \"Not Equal\"');" }, { - "text": "testNotEqual(\"bob\") should return \"Not Equal\"", - "testString": "assert(testNotEqual(\"bob\") === \"Not Equal\", 'testNotEqual(\"bob\") should return \"Not Equal\"');" + "text": "testNotEqual(\"bob\") 应该返回 \"Not Equal\"", + "testString": "assert(testNotEqual(\"bob\") === \"Not Equal\", 'testNotEqual(\"bob\") 应该返回 \"Not Equal\"');" }, { "text": "You should use the != operator", @@ -3345,20 +3345,20 @@ ], "tests": [ { - "text": "testStrictNotEqual(17) should return \"Equal\"", - "testString": "assert(testStrictNotEqual(17) === \"Equal\", 'testStrictNotEqual(17) should return \"Equal\"');" + "text": "testStrictNotEqual(17) 应该返回 \"Equal\"", + "testString": "assert(testStrictNotEqual(17) === \"Equal\", 'testStrictNotEqual(17) 应该返回 \"Equal\"');" }, { - "text": "testStrictNotEqual(\"17\") should return \"Not Equal\"", - "testString": "assert(testStrictNotEqual(\"17\") === \"Not Equal\", 'testStrictNotEqual(\"17\") should return \"Not Equal\"');" + "text": "testStrictNotEqual(\"17\") 应该返回 \"Not Equal\"", + "testString": "assert(testStrictNotEqual(\"17\") === \"Not Equal\", 'testStrictNotEqual(\"17\") 应该返回 \"Not Equal\"');" }, { - "text": "testStrictNotEqual(12) should return \"Not Equal\"", - "testString": "assert(testStrictNotEqual(12) === \"Not Equal\", 'testStrictNotEqual(12) should return \"Not Equal\"');" + "text": "testStrictNotEqual(12) 应该返回 \"Not Equal\"", + "testString": "assert(testStrictNotEqual(12) === \"Not Equal\", 'testStrictNotEqual(12) 应该返回 \"Not Equal\"');" }, { - "text": "testStrictNotEqual(\"bob\") should return \"Not Equal\"", - "testString": "assert(testStrictNotEqual(\"bob\") === \"Not Equal\", 'testStrictNotEqual(\"bob\") should return \"Not Equal\"');" + "text": "testStrictNotEqual(\"bob\") 应该返回 \"Not Equal\"", + "testString": "assert(testStrictNotEqual(\"bob\") === \"Not Equal\", 'testStrictNotEqual(\"bob\") 应该返回 \"Not Equal\"');" }, { "text": "You should use the !== operator", @@ -3410,32 +3410,32 @@ ], "tests": [ { - "text": "testGreaterThan(0) should return \"10 or Under\"", - "testString": "assert(testGreaterThan(0) === \"10 or Under\", 'testGreaterThan(0) should return \"10 or Under\"');" + "text": "testGreaterThan(0) 应该返回 \"10 or Under\"", + "testString": "assert(testGreaterThan(0) === \"10 or Under\", 'testGreaterThan(0) 应该返回 \"10 or Under\"');" }, { - "text": "testGreaterThan(10) should return \"10 or Under\"", - "testString": "assert(testGreaterThan(10) === \"10 or Under\", 'testGreaterThan(10) should return \"10 or Under\"');" + "text": "testGreaterThan(10) 应该返回 \"10 or Under\"", + "testString": "assert(testGreaterThan(10) === \"10 or Under\", 'testGreaterThan(10) 应该返回 \"10 or Under\"');" }, { - "text": "testGreaterThan(11) should return \"Over 10\"", - "testString": "assert(testGreaterThan(11) === \"Over 10\", 'testGreaterThan(11) should return \"Over 10\"');" + "text": "testGreaterThan(11) 应该返回 \"Over 10\"", + "testString": "assert(testGreaterThan(11) === \"Over 10\", 'testGreaterThan(11) 应该返回 \"Over 10\"');" }, { - "text": "testGreaterThan(99) should return \"Over 10\"", - "testString": "assert(testGreaterThan(99) === \"Over 10\", 'testGreaterThan(99) should return \"Over 10\"');" + "text": "testGreaterThan(99) 应该返回 \"Over 10\"", + "testString": "assert(testGreaterThan(99) === \"Over 10\", 'testGreaterThan(99) 应该返回 \"Over 10\"');" }, { - "text": "testGreaterThan(100) should return \"Over 10\"", - "testString": "assert(testGreaterThan(100) === \"Over 10\", 'testGreaterThan(100) should return \"Over 10\"');" + "text": "testGreaterThan(100) 应该返回 \"Over 10\"", + "testString": "assert(testGreaterThan(100) === \"Over 10\", 'testGreaterThan(100) 应该返回 \"Over 10\"');" }, { - "text": "testGreaterThan(101) should return \"Over 100\"", - "testString": "assert(testGreaterThan(101) === \"Over 100\", 'testGreaterThan(101) should return \"Over 100\"');" + "text": "testGreaterThan(101) 应该返回 \"Over 100\"", + "testString": "assert(testGreaterThan(101) === \"Over 100\", 'testGreaterThan(101) 应该返回 \"Over 100\"');" }, { - "text": "testGreaterThan(150) should return \"Over 100\"", - "testString": "assert(testGreaterThan(150) === \"Over 100\", 'testGreaterThan(150) should return \"Over 100\"');" + "text": "testGreaterThan(150) 应该返回 \"Over 100\"", + "testString": "assert(testGreaterThan(150) === \"Over 100\", 'testGreaterThan(150) 应该返回 \"Over 100\"');" }, { "text": "You should use the > operator at least twice", @@ -3486,32 +3486,32 @@ ], "tests": [ { - "text": "testGreaterOrEqual(0) should return \"Less than 10\"", - "testString": "assert(testGreaterOrEqual(0) === \"Less than 10\", 'testGreaterOrEqual(0) should return \"Less than 10\"');" + "text": "testGreaterOrEqual(0) 应该返回 \"Less than 10\"", + "testString": "assert(testGreaterOrEqual(0) === \"Less than 10\", 'testGreaterOrEqual(0) 应该返回 \"Less than 10\"');" }, { - "text": "testGreaterOrEqual(9) should return \"Less than 10\"", - "testString": "assert(testGreaterOrEqual(9) === \"Less than 10\", 'testGreaterOrEqual(9) should return \"Less than 10\"');" + "text": "testGreaterOrEqual(9) 应该返回 \"Less than 10\"", + "testString": "assert(testGreaterOrEqual(9) === \"Less than 10\", 'testGreaterOrEqual(9) 应该返回 \"Less than 10\"');" }, { - "text": "testGreaterOrEqual(10) should return \"10 or Over\"", - "testString": "assert(testGreaterOrEqual(10) === \"10 or Over\", 'testGreaterOrEqual(10) should return \"10 or Over\"');" + "text": "testGreaterOrEqual(10) 应该返回 \"10 or Over\"", + "testString": "assert(testGreaterOrEqual(10) === \"10 or Over\", 'testGreaterOrEqual(10) 应该返回 \"10 or Over\"');" }, { - "text": "testGreaterOrEqual(11) should return \"10 or Over\"", - "testString": "assert(testGreaterOrEqual(11) === \"10 or Over\", 'testGreaterOrEqual(11) should return \"10 or Over\"');" + "text": "testGreaterOrEqual(11) 应该返回 \"10 or Over\"", + "testString": "assert(testGreaterOrEqual(11) === \"10 or Over\", 'testGreaterOrEqual(11) 应该返回 \"10 or Over\"');" }, { - "text": "testGreaterOrEqual(19) should return \"10 or Over\"", - "testString": "assert(testGreaterOrEqual(19) === \"10 or Over\", 'testGreaterOrEqual(19) should return \"10 or Over\"');" + "text": "testGreaterOrEqual(19) 应该返回 \"10 or Over\"", + "testString": "assert(testGreaterOrEqual(19) === \"10 or Over\", 'testGreaterOrEqual(19) 应该返回 \"10 or Over\"');" }, { - "text": "testGreaterOrEqual(100) should return \"20 or Over\"", - "testString": "assert(testGreaterOrEqual(100) === \"20 or Over\", 'testGreaterOrEqual(100) should return \"20 or Over\"');" + "text": "testGreaterOrEqual(100) 应该返回 \"20 or Over\"", + "testString": "assert(testGreaterOrEqual(100) === \"20 or Over\", 'testGreaterOrEqual(100) 应该返回 \"20 or Over\"');" }, { - "text": "testGreaterOrEqual(21) should return \"20 or Over\"", - "testString": "assert(testGreaterOrEqual(21) === \"20 or Over\", 'testGreaterOrEqual(21) should return \"20 or Over\"');" + "text": "testGreaterOrEqual(21) 应该返回 \"20 or Over\"", + "testString": "assert(testGreaterOrEqual(21) === \"20 or Over\", 'testGreaterOrEqual(21) 应该返回 \"20 or Over\"');" }, { "text": "You should use the >= operator at least twice", @@ -3561,28 +3561,28 @@ ], "tests": [ { - "text": "testLessThan(0) should return \"Under 25\"", - "testString": "assert(testLessThan(0) === \"Under 25\", 'testLessThan(0) should return \"Under 25\"');" + "text": "testLessThan(0) 应该返回 \"Under 25\"", + "testString": "assert(testLessThan(0) === \"Under 25\", 'testLessThan(0) 应该返回 \"Under 25\"');" }, { - "text": "testLessThan(24) should return \"Under 25\"", - "testString": "assert(testLessThan(24) === \"Under 25\", 'testLessThan(24) should return \"Under 25\"');" + "text": "testLessThan(24) 应该返回 \"Under 25\"", + "testString": "assert(testLessThan(24) === \"Under 25\", 'testLessThan(24) 应该返回 \"Under 25\"');" }, { - "text": "testLessThan(25) should return \"Under 55\"", - "testString": "assert(testLessThan(25) === \"Under 55\", 'testLessThan(25) should return \"Under 55\"');" + "text": "testLessThan(25) 应该返回 \"Under 55\"", + "testString": "assert(testLessThan(25) === \"Under 55\", 'testLessThan(25) 应该返回 \"Under 55\"');" }, { - "text": "testLessThan(54) should return \"Under 55\"", - "testString": "assert(testLessThan(54) === \"Under 55\", 'testLessThan(54) should return \"Under 55\"');" + "text": "testLessThan(54) 应该返回 \"Under 55\"", + "testString": "assert(testLessThan(54) === \"Under 55\", 'testLessThan(54) 应该返回 \"Under 55\"');" }, { - "text": "testLessThan(55) should return \"55 or Over\"", - "testString": "assert(testLessThan(55) === \"55 or Over\", 'testLessThan(55) should return \"55 or Over\"');" + "text": "testLessThan(55) 应该返回 \"55 or Over\"", + "testString": "assert(testLessThan(55) === \"55 or Over\", 'testLessThan(55) 应该返回 \"55 or Over\"');" }, { - "text": "testLessThan(99) should return \"55 or Over\"", - "testString": "assert(testLessThan(99) === \"55 or Over\", 'testLessThan(99) should return \"55 or Over\"');" + "text": "testLessThan(99) 应该返回 \"55 or Over\"", + "testString": "assert(testLessThan(99) === \"55 or Over\", 'testLessThan(99) 应该返回 \"55 or Over\"');" }, { "text": "You should use the < operator at least twice", @@ -3632,32 +3632,32 @@ ], "tests": [ { - "text": "testLessOrEqual(0) should return \"Smaller Than or Equal to 12\"", - "testString": "assert(testLessOrEqual(0) === \"Smaller Than or Equal to 12\", 'testLessOrEqual(0) should return \"Smaller Than or Equal to 12\"');" + "text": "testLessOrEqual(0) 应该返回 \"Smaller Than or Equal to 12\"", + "testString": "assert(testLessOrEqual(0) === \"Smaller Than or Equal to 12\", 'testLessOrEqual(0) 应该返回 \"Smaller Than or Equal to 12\"');" }, { - "text": "testLessOrEqual(11) should return \"Smaller Than or Equal to 12\"", - "testString": "assert(testLessOrEqual(11) === \"Smaller Than or Equal to 12\", 'testLessOrEqual(11) should return \"Smaller Than or Equal to 12\"');" + "text": "testLessOrEqual(11) 应该返回 \"Smaller Than or Equal to 12\"", + "testString": "assert(testLessOrEqual(11) === \"Smaller Than or Equal to 12\", 'testLessOrEqual(11) 应该返回 \"Smaller Than or Equal to 12\"');" }, { - "text": "testLessOrEqual(12) should return \"Smaller Than or Equal to 12\"", - "testString": "assert(testLessOrEqual(12) === \"Smaller Than or Equal to 12\", 'testLessOrEqual(12) should return \"Smaller Than or Equal to 12\"');" + "text": "testLessOrEqual(12) 应该返回 \"Smaller Than or Equal to 12\"", + "testString": "assert(testLessOrEqual(12) === \"Smaller Than or Equal to 12\", 'testLessOrEqual(12) 应该返回 \"Smaller Than or Equal to 12\"');" }, { - "text": "testLessOrEqual(23) should return \"Smaller Than or Equal to 24\"", - "testString": "assert(testLessOrEqual(23) === \"Smaller Than or Equal to 24\", 'testLessOrEqual(23) should return \"Smaller Than or Equal to 24\"');" + "text": "testLessOrEqual(23) 应该返回 \"Smaller Than or Equal to 24\"", + "testString": "assert(testLessOrEqual(23) === \"Smaller Than or Equal to 24\", 'testLessOrEqual(23) 应该返回 \"Smaller Than or Equal to 24\"');" }, { - "text": "testLessOrEqual(24) should return \"Smaller Than or Equal to 24\"", - "testString": "assert(testLessOrEqual(24) === \"Smaller Than or Equal to 24\", 'testLessOrEqual(24) should return \"Smaller Than or Equal to 24\"');" + "text": "testLessOrEqual(24) 应该返回 \"Smaller Than or Equal to 24\"", + "testString": "assert(testLessOrEqual(24) === \"Smaller Than or Equal to 24\", 'testLessOrEqual(24) 应该返回 \"Smaller Than or Equal to 24\"');" }, { - "text": "testLessOrEqual(25) should return \"More Than 24\"", - "testString": "assert(testLessOrEqual(25) === \"More Than 24\", 'testLessOrEqual(25) should return \"More Than 24\"');" + "text": "testLessOrEqual(25) 应该返回 \"More Than 24\"", + "testString": "assert(testLessOrEqual(25) === \"More Than 24\", 'testLessOrEqual(25) 应该返回 \"More Than 24\"');" }, { - "text": "testLessOrEqual(55) should return \"More Than 24\"", - "testString": "assert(testLessOrEqual(55) === \"More Than 24\", 'testLessOrEqual(55) should return \"More Than 24\"');" + "text": "testLessOrEqual(55) 应该返回 \"More Than 24\"", + "testString": "assert(testLessOrEqual(55) === \"More Than 24\", 'testLessOrEqual(55) 应该返回 \"More Than 24\"');" }, { "text": "You should use the <= operator at least twice", @@ -3718,36 +3718,36 @@ "testString": "assert(code.match(/if/g).length === 1, 'You should only have one if statement');" }, { - "text": "testLogicalAnd(0) should return \"No\"", - "testString": "assert(testLogicalAnd(0) === \"No\", 'testLogicalAnd(0) should return \"No\"');" + "text": "testLogicalAnd(0) 应该返回 \"No\"", + "testString": "assert(testLogicalAnd(0) === \"No\", 'testLogicalAnd(0) 应该返回 \"No\"');" }, { - "text": "testLogicalAnd(24) should return \"No\"", - "testString": "assert(testLogicalAnd(24) === \"No\", 'testLogicalAnd(24) should return \"No\"');" + "text": "testLogicalAnd(24) 应该返回 \"No\"", + "testString": "assert(testLogicalAnd(24) === \"No\", 'testLogicalAnd(24) 应该返回 \"No\"');" }, { - "text": "testLogicalAnd(25) should return \"Yes\"", - "testString": "assert(testLogicalAnd(25) === \"Yes\", 'testLogicalAnd(25) should return \"Yes\"');" + "text": "testLogicalAnd(25) 应该返回 \"Yes\"", + "testString": "assert(testLogicalAnd(25) === \"Yes\", 'testLogicalAnd(25) 应该返回 \"Yes\"');" }, { - "text": "testLogicalAnd(30) should return \"Yes\"", - "testString": "assert(testLogicalAnd(30) === \"Yes\", 'testLogicalAnd(30) should return \"Yes\"');" + "text": "testLogicalAnd(30) 应该返回 \"Yes\"", + "testString": "assert(testLogicalAnd(30) === \"Yes\", 'testLogicalAnd(30) 应该返回 \"Yes\"');" }, { - "text": "testLogicalAnd(50) should return \"Yes\"", - "testString": "assert(testLogicalAnd(50) === \"Yes\", 'testLogicalAnd(50) should return \"Yes\"');" + "text": "testLogicalAnd(50) 应该返回 \"Yes\"", + "testString": "assert(testLogicalAnd(50) === \"Yes\", 'testLogicalAnd(50) 应该返回 \"Yes\"');" }, { - "text": "testLogicalAnd(51) should return \"No\"", - "testString": "assert(testLogicalAnd(51) === \"No\", 'testLogicalAnd(51) should return \"No\"');" + "text": "testLogicalAnd(51) 应该返回 \"No\"", + "testString": "assert(testLogicalAnd(51) === \"No\", 'testLogicalAnd(51) 应该返回 \"No\"');" }, { - "text": "testLogicalAnd(75) should return \"No\"", - "testString": "assert(testLogicalAnd(75) === \"No\", 'testLogicalAnd(75) should return \"No\"');" + "text": "testLogicalAnd(75) 应该返回 \"No\"", + "testString": "assert(testLogicalAnd(75) === \"No\", 'testLogicalAnd(75) 应该返回 \"No\"');" }, { - "text": "testLogicalAnd(80) should return \"No\"", - "testString": "assert(testLogicalAnd(80) === \"No\", 'testLogicalAnd(80) should return \"No\"');" + "text": "testLogicalAnd(80) 应该返回 \"No\"", + "testString": "assert(testLogicalAnd(80) === \"No\", 'testLogicalAnd(80) 应该返回 \"No\"');" } ], "challengeType": 1, @@ -3805,36 +3805,36 @@ "testString": "assert(code.match(/if/g).length === 1, 'You should only have one if statement');" }, { - "text": "testLogicalOr(0) should return \"Outside\"", - "testString": "assert(testLogicalOr(0) === \"Outside\", 'testLogicalOr(0) should return \"Outside\"');" + "text": "testLogicalOr(0) 应该返回 \"Outside\"", + "testString": "assert(testLogicalOr(0) === \"Outside\", 'testLogicalOr(0) 应该返回 \"Outside\"');" }, { - "text": "testLogicalOr(9) should return \"Outside\"", - "testString": "assert(testLogicalOr(9) === \"Outside\", 'testLogicalOr(9) should return \"Outside\"');" + "text": "testLogicalOr(9) 应该返回 \"Outside\"", + "testString": "assert(testLogicalOr(9) === \"Outside\", 'testLogicalOr(9) 应该返回 \"Outside\"');" }, { - "text": "testLogicalOr(10) should return \"Inside\"", - "testString": "assert(testLogicalOr(10) === \"Inside\", 'testLogicalOr(10) should return \"Inside\"');" + "text": "testLogicalOr(10) 应该返回 \"Inside\"", + "testString": "assert(testLogicalOr(10) === \"Inside\", 'testLogicalOr(10) 应该返回 \"Inside\"');" }, { - "text": "testLogicalOr(15) should return \"Inside\"", - "testString": "assert(testLogicalOr(15) === \"Inside\", 'testLogicalOr(15) should return \"Inside\"');" + "text": "testLogicalOr(15) 应该返回 \"Inside\"", + "testString": "assert(testLogicalOr(15) === \"Inside\", 'testLogicalOr(15) 应该返回 \"Inside\"');" }, { - "text": "testLogicalOr(19) should return \"Inside\"", - "testString": "assert(testLogicalOr(19) === \"Inside\", 'testLogicalOr(19) should return \"Inside\"');" + "text": "testLogicalOr(19) 应该返回 \"Inside\"", + "testString": "assert(testLogicalOr(19) === \"Inside\", 'testLogicalOr(19) 应该返回 \"Inside\"');" }, { - "text": "testLogicalOr(20) should return \"Inside\"", - "testString": "assert(testLogicalOr(20) === \"Inside\", 'testLogicalOr(20) should return \"Inside\"');" + "text": "testLogicalOr(20) 应该返回 \"Inside\"", + "testString": "assert(testLogicalOr(20) === \"Inside\", 'testLogicalOr(20) 应该返回 \"Inside\"');" }, { - "text": "testLogicalOr(21) should return \"Outside\"", - "testString": "assert(testLogicalOr(21) === \"Outside\", 'testLogicalOr(21) should return \"Outside\"');" + "text": "testLogicalOr(21) 应该返回 \"Outside\"", + "testString": "assert(testLogicalOr(21) === \"Outside\", 'testLogicalOr(21) 应该返回 \"Outside\"');" }, { - "text": "testLogicalOr(25) should return \"Outside\"", - "testString": "assert(testLogicalOr(25) === \"Outside\", 'testLogicalOr(25) should return \"Outside\"');" + "text": "testLogicalOr(25) 应该返回 \"Outside\"", + "testString": "assert(testLogicalOr(25) === \"Outside\", 'testLogicalOr(25) 应该返回 \"Outside\"');" } ], "challengeType": 1, @@ -3890,20 +3890,20 @@ "testString": "assert(/else/g.test(code), 'You should use an else statement');" }, { - "text": "testElse(4) should return \"5 or Smaller\"", - "testString": "assert(testElse(4) === \"5 or Smaller\", 'testElse(4) should return \"5 or Smaller\"');" + "text": "testElse(4) 应该返回 \"5 or Smaller\"", + "testString": "assert(testElse(4) === \"5 or Smaller\", 'testElse(4) 应该返回 \"5 or Smaller\"');" }, { - "text": "testElse(5) should return \"5 or Smaller\"", - "testString": "assert(testElse(5) === \"5 or Smaller\", 'testElse(5) should return \"5 or Smaller\"');" + "text": "testElse(5) 应该返回 \"5 or Smaller\"", + "testString": "assert(testElse(5) === \"5 or Smaller\", 'testElse(5) 应该返回 \"5 or Smaller\"');" }, { - "text": "testElse(6) should return \"Bigger than 5\"", - "testString": "assert(testElse(6) === \"Bigger than 5\", 'testElse(6) should return \"Bigger than 5\"');" + "text": "testElse(6) 应该返回 \"Bigger than 5\"", + "testString": "assert(testElse(6) === \"Bigger than 5\", 'testElse(6) 应该返回 \"Bigger than 5\"');" }, { - "text": "testElse(10) should return \"Bigger than 5\"", - "testString": "assert(testElse(10) === \"Bigger than 5\", 'testElse(10) should return \"Bigger than 5\"');" + "text": "testElse(10) 应该返回 \"Bigger than 5\"", + "testString": "assert(testElse(10) === \"Bigger than 5\", 'testElse(10) 应该返回 \"Bigger than 5\"');" }, { "text": "Do not change the code above or below the lines.", @@ -3965,24 +3965,24 @@ "testString": "assert(code.match(/if/g).length > 1, 'You should have at least two if statements');" }, { - "text": "testElseIf(0) should return \"Smaller than 5\"", - "testString": "assert(testElseIf(0) === \"Smaller than 5\", 'testElseIf(0) should return \"Smaller than 5\"');" + "text": "testElseIf(0) 应该返回 \"Smaller than 5\"", + "testString": "assert(testElseIf(0) === \"Smaller than 5\", 'testElseIf(0) 应该返回 \"Smaller than 5\"');" }, { - "text": "testElseIf(5) should return \"Between 5 and 10\"", - "testString": "assert(testElseIf(5) === \"Between 5 and 10\", 'testElseIf(5) should return \"Between 5 and 10\"');" + "text": "testElseIf(5) 应该返回 \"Between 5 and 10\"", + "testString": "assert(testElseIf(5) === \"Between 5 and 10\", 'testElseIf(5) 应该返回 \"Between 5 and 10\"');" }, { - "text": "testElseIf(7) should return \"Between 5 and 10\"", - "testString": "assert(testElseIf(7) === \"Between 5 and 10\", 'testElseIf(7) should return \"Between 5 and 10\"');" + "text": "testElseIf(7) 应该返回 \"Between 5 and 10\"", + "testString": "assert(testElseIf(7) === \"Between 5 and 10\", 'testElseIf(7) 应该返回 \"Between 5 and 10\"');" }, { - "text": "testElseIf(10) should return \"Between 5 and 10\"", - "testString": "assert(testElseIf(10) === \"Between 5 and 10\", 'testElseIf(10) should return \"Between 5 and 10\"');" + "text": "testElseIf(10) 应该返回 \"Between 5 and 10\"", + "testString": "assert(testElseIf(10) === \"Between 5 and 10\", 'testElseIf(10) 应该返回 \"Between 5 and 10\"');" }, { - "text": "testElseIf(12) should return \"Greater than 10\"", - "testString": "assert(testElseIf(12) === \"Greater than 10\", 'testElseIf(12) should return \"Greater than 10\"');" + "text": "testElseIf(12) 应该返回 \"Greater than 10\"", + "testString": "assert(testElseIf(12) === \"Greater than 10\", 'testElseIf(12) 应该返回 \"Greater than 10\"');" } ], "challengeType": 1, @@ -4034,16 +4034,16 @@ ], "tests": [ { - "text": "orderMyLogic(4) should return \"Less than 5\"", - "testString": "assert(orderMyLogic(4) === \"Less than 5\", 'orderMyLogic(4) should return \"Less than 5\"');" + "text": "orderMyLogic(4) 应该返回 \"Less than 5\"", + "testString": "assert(orderMyLogic(4) === \"Less than 5\", 'orderMyLogic(4) 应该返回 \"Less than 5\"');" }, { - "text": "orderMyLogic(6) should return \"Less than 10\"", - "testString": "assert(orderMyLogic(6) === \"Less than 10\", 'orderMyLogic(6) should return \"Less than 10\"');" + "text": "orderMyLogic(6) 应该返回 \"Less than 10\"", + "testString": "assert(orderMyLogic(6) === \"Less than 10\", 'orderMyLogic(6) 应该返回 \"Less than 10\"');" }, { - "text": "orderMyLogic(11) should return \"Greater than or equal to 10\"", - "testString": "assert(orderMyLogic(11) === \"Greater than or equal to 10\", 'orderMyLogic(11) should return \"Greater than or equal to 10\"');" + "text": "orderMyLogic(11) 应该返回 \"Greater than or equal to 10\"", + "testString": "assert(orderMyLogic(11) === \"Greater than or equal to 10\", 'orderMyLogic(11) 应该返回 \"Greater than or equal to 10\"');" } ], "challengeType": 1, @@ -4099,44 +4099,44 @@ "testString": "assert(code.match(/return/g).length >= 1, 'You should have at least one return statement');" }, { - "text": "testSize(0) should return \"Tiny\"", - "testString": "assert(testSize(0) === \"Tiny\", 'testSize(0) should return \"Tiny\"');" + "text": "testSize(0) 应该返回 \"Tiny\"", + "testString": "assert(testSize(0) === \"Tiny\", 'testSize(0) 应该返回 \"Tiny\"');" }, { - "text": "testSize(4) should return \"Tiny\"", - "testString": "assert(testSize(4) === \"Tiny\", 'testSize(4) should return \"Tiny\"');" + "text": "testSize(4) 应该返回 \"Tiny\"", + "testString": "assert(testSize(4) === \"Tiny\", 'testSize(4) 应该返回 \"Tiny\"');" }, { - "text": "testSize(5) should return \"Small\"", - "testString": "assert(testSize(5) === \"Small\", 'testSize(5) should return \"Small\"');" + "text": "testSize(5) 应该返回 \"Small\"", + "testString": "assert(testSize(5) === \"Small\", 'testSize(5) 应该返回 \"Small\"');" }, { - "text": "testSize(8) should return \"Small\"", - "testString": "assert(testSize(8) === \"Small\", 'testSize(8) should return \"Small\"');" + "text": "testSize(8) 应该返回 \"Small\"", + "testString": "assert(testSize(8) === \"Small\", 'testSize(8) 应该返回 \"Small\"');" }, { - "text": "testSize(10) should return \"Medium\"", - "testString": "assert(testSize(10) === \"Medium\", 'testSize(10) should return \"Medium\"');" + "text": "testSize(10) 应该返回 \"Medium\"", + "testString": "assert(testSize(10) === \"Medium\", 'testSize(10) 应该返回 \"Medium\"');" }, { - "text": "testSize(14) should return \"Medium\"", - "testString": "assert(testSize(14) === \"Medium\", 'testSize(14) should return \"Medium\"');" + "text": "testSize(14) 应该返回 \"Medium\"", + "testString": "assert(testSize(14) === \"Medium\", 'testSize(14) 应该返回 \"Medium\"');" }, { - "text": "testSize(15) should return \"Large\"", - "testString": "assert(testSize(15) === \"Large\", 'testSize(15) should return \"Large\"');" + "text": "testSize(15) 应该返回 \"Large\"", + "testString": "assert(testSize(15) === \"Large\", 'testSize(15) 应该返回 \"Large\"');" }, { - "text": "testSize(17) should return \"Large\"", - "testString": "assert(testSize(17) === \"Large\", 'testSize(17) should return \"Large\"');" + "text": "testSize(17) 应该返回 \"Large\"", + "testString": "assert(testSize(17) === \"Large\", 'testSize(17) 应该返回 \"Large\"');" }, { - "text": "testSize(20) should return \"Huge\"", - "testString": "assert(testSize(20) === \"Huge\", 'testSize(20) should return \"Huge\"');" + "text": "testSize(20) 应该返回 \"Huge\"", + "testString": "assert(testSize(20) === \"Huge\", 'testSize(20) 应该返回 \"Huge\"');" }, { - "text": "testSize(25) should return \"Huge\"", - "testString": "assert(testSize(25) === \"Huge\", 'testSize(25) should return \"Huge\"');" + "text": "testSize(25) 应该返回 \"Huge\"", + "testString": "assert(testSize(25) === \"Huge\", 'testSize(25) 应该返回 \"Huge\"');" } ], "challengeType": 1, @@ -4177,48 +4177,48 @@ ], "tests": [ { - "text": "golfScore(4, 1) should return \"Hole-in-one!\"", - "testString": "assert(golfScore(4, 1) === \"Hole-in-one!\", 'golfScore(4, 1) should return \"Hole-in-one!\"');" + "text": "golfScore(4, 1) 应该返回 \"Hole-in-one!\"", + "testString": "assert(golfScore(4, 1) === \"Hole-in-one!\", 'golfScore(4, 1) 应该返回 \"Hole-in-one!\"');" }, { - "text": "golfScore(4, 2) should return \"Eagle\"", - "testString": "assert(golfScore(4, 2) === \"Eagle\", 'golfScore(4, 2) should return \"Eagle\"');" + "text": "golfScore(4, 2) 应该返回 \"Eagle\"", + "testString": "assert(golfScore(4, 2) === \"Eagle\", 'golfScore(4, 2) 应该返回 \"Eagle\"');" }, { - "text": "golfScore(5, 2) should return \"Eagle\"", - "testString": "assert(golfScore(5, 2) === \"Eagle\", 'golfScore(5, 2) should return \"Eagle\"');" + "text": "golfScore(5, 2) 应该返回 \"Eagle\"", + "testString": "assert(golfScore(5, 2) === \"Eagle\", 'golfScore(5, 2) 应该返回 \"Eagle\"');" }, { - "text": "golfScore(4, 3) should return \"Birdie\"", - "testString": "assert(golfScore(4, 3) === \"Birdie\", 'golfScore(4, 3) should return \"Birdie\"');" + "text": "golfScore(4, 3) 应该返回 \"Birdie\"", + "testString": "assert(golfScore(4, 3) === \"Birdie\", 'golfScore(4, 3) 应该返回 \"Birdie\"');" }, { - "text": "golfScore(4, 4) should return \"Par\"", - "testString": "assert(golfScore(4, 4) === \"Par\", 'golfScore(4, 4) should return \"Par\"');" + "text": "golfScore(4, 4) 应该返回 \"Par\"", + "testString": "assert(golfScore(4, 4) === \"Par\", 'golfScore(4, 4) 应该返回 \"Par\"');" }, { - "text": "golfScore(1, 1) should return \"Hole-in-one!\"", - "testString": "assert(golfScore(1, 1) === \"Hole-in-one!\", 'golfScore(1, 1) should return \"Hole-in-one!\"');" + "text": "golfScore(1, 1) 应该返回 \"Hole-in-one!\"", + "testString": "assert(golfScore(1, 1) === \"Hole-in-one!\", 'golfScore(1, 1) 应该返回 \"Hole-in-one!\"');" }, { - "text": "golfScore(5, 5) should return \"Par\"", - "testString": "assert(golfScore(5, 5) === \"Par\", 'golfScore(5, 5) should return \"Par\"');" + "text": "golfScore(5, 5) 应该返回 \"Par\"", + "testString": "assert(golfScore(5, 5) === \"Par\", 'golfScore(5, 5) 应该返回 \"Par\"');" }, { - "text": "golfScore(4, 5) should return \"Bogey\"", - "testString": "assert(golfScore(4, 5) === \"Bogey\", 'golfScore(4, 5) should return \"Bogey\"');" + "text": "golfScore(4, 5) 应该返回 \"Bogey\"", + "testString": "assert(golfScore(4, 5) === \"Bogey\", 'golfScore(4, 5) 应该返回 \"Bogey\"');" }, { - "text": "golfScore(4, 6) should return \"Double Bogey\"", - "testString": "assert(golfScore(4, 6) === \"Double Bogey\", 'golfScore(4, 6) should return \"Double Bogey\"');" + "text": "golfScore(4, 6) 应该返回 \"Double Bogey\"", + "testString": "assert(golfScore(4, 6) === \"Double Bogey\", 'golfScore(4, 6) 应该返回 \"Double Bogey\"');" }, { - "text": "golfScore(4, 7) should return \"Go Home!\"", - "testString": "assert(golfScore(4, 7) === \"Go Home!\", 'golfScore(4, 7) should return \"Go Home!\"');" + "text": "golfScore(4, 7) 应该返回 \"Go Home!\"", + "testString": "assert(golfScore(4, 7) === \"Go Home!\", 'golfScore(4, 7) 应该返回 \"Go Home!\"');" }, { - "text": "golfScore(5, 9) should return \"Go Home!\"", - "testString": "assert(golfScore(5, 9) === \"Go Home!\", 'golfScore(5, 9) should return \"Go Home!\"');" + "text": "golfScore(5, 9) 应该返回 \"Go Home!\"", + "testString": "assert(golfScore(5, 9) === \"Go Home!\", 'golfScore(5, 9) 应该返回 \"Go Home!\"');" } ], "challengeType": 1, @@ -4407,40 +4407,40 @@ ], "tests": [ { - "text": "sequentialSizes(1) should return \"Low\"", - "testString": "assert(sequentialSizes(1) === \"Low\", 'sequentialSizes(1) should return \"Low\"');" + "text": "sequentialSizes(1) 应该返回 \"Low\"", + "testString": "assert(sequentialSizes(1) === \"Low\", 'sequentialSizes(1) 应该返回 \"Low\"');" }, { - "text": "sequentialSizes(2) should return \"Low\"", - "testString": "assert(sequentialSizes(2) === \"Low\", 'sequentialSizes(2) should return \"Low\"');" + "text": "sequentialSizes(2) 应该返回 \"Low\"", + "testString": "assert(sequentialSizes(2) === \"Low\", 'sequentialSizes(2) 应该返回 \"Low\"');" }, { - "text": "sequentialSizes(3) should return \"Low\"", - "testString": "assert(sequentialSizes(3) === \"Low\", 'sequentialSizes(3) should return \"Low\"');" + "text": "sequentialSizes(3) 应该返回 \"Low\"", + "testString": "assert(sequentialSizes(3) === \"Low\", 'sequentialSizes(3) 应该返回 \"Low\"');" }, { - "text": "sequentialSizes(4) should return \"Mid\"", - "testString": "assert(sequentialSizes(4) === \"Mid\", 'sequentialSizes(4) should return \"Mid\"');" + "text": "sequentialSizes(4) 应该返回 \"Mid\"", + "testString": "assert(sequentialSizes(4) === \"Mid\", 'sequentialSizes(4) 应该返回 \"Mid\"');" }, { - "text": "sequentialSizes(5) should return \"Mid\"", - "testString": "assert(sequentialSizes(5) === \"Mid\", 'sequentialSizes(5) should return \"Mid\"');" + "text": "sequentialSizes(5) 应该返回 \"Mid\"", + "testString": "assert(sequentialSizes(5) === \"Mid\", 'sequentialSizes(5) 应该返回 \"Mid\"');" }, { - "text": "sequentialSizes(6) should return \"Mid\"", - "testString": "assert(sequentialSizes(6) === \"Mid\", 'sequentialSizes(6) should return \"Mid\"');" + "text": "sequentialSizes(6) 应该返回 \"Mid\"", + "testString": "assert(sequentialSizes(6) === \"Mid\", 'sequentialSizes(6) 应该返回 \"Mid\"');" }, { - "text": "sequentialSizes(7) should return \"High\"", - "testString": "assert(sequentialSizes(7) === \"High\", 'sequentialSizes(7) should return \"High\"');" + "text": "sequentialSizes(7) 应该返回 \"High\"", + "testString": "assert(sequentialSizes(7) === \"High\", 'sequentialSizes(7) 应该返回 \"High\"');" }, { - "text": "sequentialSizes(8) should return \"High\"", - "testString": "assert(sequentialSizes(8) === \"High\", 'sequentialSizes(8) should return \"High\"');" + "text": "sequentialSizes(8) 应该返回 \"High\"", + "testString": "assert(sequentialSizes(8) === \"High\", 'sequentialSizes(8) 应该返回 \"High\"');" }, { - "text": "sequentialSizes(9) should return \"High\"", - "testString": "assert(sequentialSizes(9) === \"High\", 'sequentialSizes(9) should return \"High\"');" + "text": "sequentialSizes(9) 应该返回 \"High\"", + "testString": "assert(sequentialSizes(9) === \"High\", 'sequentialSizes(9) 应该返回 \"High\"');" }, { "text": "You should not use any if or else statements", @@ -4588,12 +4588,12 @@ ], "tests": [ { - "text": "isLess(10,15) should return true", - "testString": "assert(isLess(10,15) === true, 'isLess(10,15) should return true');" + "text": "isLess(10,15) 应该返回 true", + "testString": "assert(isLess(10,15) === true, 'isLess(10,15) 应该返回 true');" }, { - "text": "isLess(15,10) should return false", - "testString": "assert(isLess(15, 10) === false, 'isLess(15,10) should return false');" + "text": "isLess(15,10) 应该返回 false", + "testString": "assert(isLess(15, 10) === false, 'isLess(15,10) 应该返回 false');" }, { "text": "You should not use any if or else statements", @@ -4642,28 +4642,28 @@ ], "tests": [ { - "text": "abTest(2,2) should return a number", - "testString": "assert(typeof abTest(2,2) === 'number' , 'abTest(2,2) should return a number');" + "text": "abTest(2,2) 应该返回一个数字", + "testString": "assert(typeof abTest(2,2) === 'number' , 'abTest(2,2) 应该返回一个数字');" }, { - "text": "abTest(2,2) should return 8", - "testString": "assert(abTest(2,2) === 8 , 'abTest(2,2) should return 8');" + "text": "abTest(2,2) 应该返回 8", + "testString": "assert(abTest(2,2) === 8 , 'abTest(2,2) 应该返回 8');" }, { - "text": "abTest(-2,2) should return undefined", - "testString": "assert(abTest(-2,2) === undefined , 'abTest(-2,2) should return undefined');" + "text": "abTest(-2,2) 应该返回 undefined", + "testString": "assert(abTest(-2,2) === undefined , 'abTest(-2,2) 应该返回 undefined');" }, { - "text": "abTest(2,-2) should return undefined", - "testString": "assert(abTest(2,-2) === undefined , 'abTest(2,-2) should return undefined');" + "text": "abTest(2,-2) 应该返回 undefined", + "testString": "assert(abTest(2,-2) === undefined , 'abTest(2,-2) 应该返回 undefined');" }, { - "text": "abTest(2,8) should return 18", - "testString": "assert(abTest(2,8) === 18 , 'abTest(2,8) should return 18');" + "text": "abTest(2,8) 应该返回 18", + "testString": "assert(abTest(2,8) === 18 , 'abTest(2,8) 应该返回 18');" }, { - "text": "abTest(3,3) should return 12", - "testString": "assert(abTest(3,3) === 12 , 'abTest(3,3) should return 12');" + "text": "abTest(3,3) 应该返回 12", + "testString": "assert(abTest(3,3) === 12 , 'abTest(3,3) 应该返回 12');" } ], "challengeType": 1, @@ -4709,32 +4709,32 @@ ], "tests": [ { - "text": "Cards Sequence 2, 3, 4, 5, 6 should return 5 Bet", - "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 5 Bet');" + "text": "Cards Sequence 2, 3, 4, 5, 6 应该返回 5 Bet", + "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 应该返回 5 Bet');" }, { - "text": "Cards Sequence 7, 8, 9 should return 0 Hold", - "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 0 Hold');" + "text": "Cards Sequence 7, 8, 9 应该返回 0 Hold", + "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 应该返回 0 Hold');" }, { - "text": "Cards Sequence 10, J, Q, K, A should return -5 Hold", - "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 -5 Hold');" + "text": "Cards Sequence 10, J, Q, K, A 应该返回 -5 Hold", + "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 应该返回 -5 Hold');" }, { - "text": "Cards Sequence 3, 7, Q, 8, A should return -1 Hold", - "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 -1 Hold');" + "text": "Cards Sequence 3, 7, Q, 8, A 应该返回 -1 Hold", + "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 应该返回 -1 Hold');" }, { - "text": "Cards Sequence 2, J, 9, 2, 7 should return 1 Bet", - "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 1 Bet');" + "text": "Cards Sequence 2, J, 9, 2, 7 应该返回 1 Bet", + "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 应该返回 1 Bet');" }, { - "text": "Cards Sequence 2, 2, 10 should return 1 Bet", - "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 1 Bet');" + "text": "Cards Sequence 2, 2, 10 应该返回 1 Bet", + "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 应该返回 1 Bet');" }, { - "text": "Cards Sequence 3, 2, A, 10, K should return -1 Hold", - "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 -1 Hold');" + "text": "Cards Sequence 3, 2, A, 10, K 应该返回 -1 Hold", + "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 应该返回 -1 Hold');" } ], "challengeType": 1, @@ -4852,16 +4852,16 @@ ], "tests": [ { - "text": "hatValue should be a string", - "testString": "assert(typeof hatValue === 'string' , 'hatValue should be a string');" + "text": "hatValue 应该是一个字符串。", + "testString": "assert(typeof hatValue === 'string' , 'hatValue 应该是一个字符串。');" }, { "text": "The value of hatValue should be \"ballcap\"", "testString": "assert(hatValue === 'ballcap' , 'The value of hatValue should be \"ballcap\"');" }, { - "text": "shirtValue should be a string", - "testString": "assert(typeof shirtValue === 'string' , 'shirtValue should be a string');" + "text": "shirtValue 应该是一个字符串。", + "testString": "assert(typeof shirtValue === 'string' , 'shirtValue 应该是一个字符串。');" }, { "text": "The value of shirtValue should be \"jersey\"", @@ -4916,16 +4916,16 @@ ], "tests": [ { - "text": "entreeValue should be a string", - "testString": "assert(typeof entreeValue === 'string' , 'entreeValue should be a string');" + "text": "entreeValue 应该是一个字符串。", + "testString": "assert(typeof entreeValue === 'string' , 'entreeValue 应该是一个字符串。');" }, { "text": "The value of entreeValue should be \"hamburger\"", "testString": "assert(entreeValue === 'hamburger' , 'The value of entreeValue should be \"hamburger\"');" }, { - "text": "drinkValue should be a string", - "testString": "assert(typeof drinkValue === 'string' , 'drinkValue should be a string');" + "text": "drinkValue 应该是一个字符串。", + "testString": "assert(typeof drinkValue === 'string' , 'drinkValue 应该是一个字符串。');" }, { "text": "The value of drinkValue should be \"water\"", @@ -4986,8 +4986,8 @@ "testString": "assert(typeof playerNumber === 'number', 'playerNumber should be a number');" }, { - "text": "The variable player should be a string", - "testString": "assert(typeof player === 'string', 'The variable player should be a string');" + "text": "变量 player 应该是一个字符串。", + "testString": "assert(typeof player === 'string', '变量 player 应该是一个字符串。');" }, { "text": "The value of player should be \"Montana\"", @@ -5233,32 +5233,32 @@ ], "tests": [ { - "text": "phoneticLookup(\"alpha\") should equal \"Adams\"", - "testString": "assert(phoneticLookup(\"alpha\") === 'Adams', 'phoneticLookup(\"alpha\") should equal \"Adams\"');" + "text": "phoneticLookup(\"alpha\") 应该等于 \"Adams\"", + "testString": "assert(phoneticLookup(\"alpha\") === 'Adams', 'phoneticLookup(\"alpha\") 应该等于 \"Adams\"');" }, { - "text": "phoneticLookup(\"bravo\") should equal \"Boston\"", - "testString": "assert(phoneticLookup(\"bravo\") === 'Boston', 'phoneticLookup(\"bravo\") should equal \"Boston\"');" + "text": "phoneticLookup(\"bravo\") 应该等于 \"Boston\"", + "testString": "assert(phoneticLookup(\"bravo\") === 'Boston', 'phoneticLookup(\"bravo\") 应该等于 \"Boston\"');" }, { - "text": "phoneticLookup(\"charlie\") should equal \"Chicago\"", - "testString": "assert(phoneticLookup(\"charlie\") === 'Chicago', 'phoneticLookup(\"charlie\") should equal \"Chicago\"');" + "text": "phoneticLookup(\"charlie\") 应该等于 \"Chicago\"", + "testString": "assert(phoneticLookup(\"charlie\") === 'Chicago', 'phoneticLookup(\"charlie\") 应该等于 \"Chicago\"');" }, { - "text": "phoneticLookup(\"delta\") should equal \"Denver\"", - "testString": "assert(phoneticLookup(\"delta\") === 'Denver', 'phoneticLookup(\"delta\") should equal \"Denver\"');" + "text": "phoneticLookup(\"delta\") 应该等于 \"Denver\"", + "testString": "assert(phoneticLookup(\"delta\") === 'Denver', 'phoneticLookup(\"delta\") 应该等于 \"Denver\"');" }, { - "text": "phoneticLookup(\"echo\") should equal \"Easy\"", - "testString": "assert(phoneticLookup(\"echo\") === 'Easy', 'phoneticLookup(\"echo\") should equal \"Easy\"');" + "text": "phoneticLookup(\"echo\") 应该等于 \"Easy\"", + "testString": "assert(phoneticLookup(\"echo\") === 'Easy', 'phoneticLookup(\"echo\") 应该等于 \"Easy\"');" }, { - "text": "phoneticLookup(\"foxtrot\") should equal \"Frank\"", - "testString": "assert(phoneticLookup(\"foxtrot\") === 'Frank', 'phoneticLookup(\"foxtrot\") should equal \"Frank\"');" + "text": "phoneticLookup(\"foxtrot\") 应该等于 \"Frank\"", + "testString": "assert(phoneticLookup(\"foxtrot\") === 'Frank', 'phoneticLookup(\"foxtrot\") 应该等于 \"Frank\"');" }, { - "text": "phoneticLookup(\"\") should equal undefined", - "testString": "assert(typeof phoneticLookup(\"\") === 'undefined', 'phoneticLookup(\"\") should equal undefined');" + "text": "phoneticLookup(\"\") 应该等于 undefined", + "testString": "assert(typeof phoneticLookup(\"\") === 'undefined', 'phoneticLookup(\"\") 应该等于 undefined');" }, { "text": "You should not modify the return statement", @@ -5329,16 +5329,16 @@ ], "tests": [ { - "text": "checkObj(\"gift\") should return \"pony\".", - "testString": "assert(checkObj(\"gift\") === \"pony\", 'checkObj(\"gift\") should return \"pony\".');" + "text": "checkObj(\"gift\") 应该返回 \"pony\".", + "testString": "assert(checkObj(\"gift\") === \"pony\", 'checkObj(\"gift\") 应该返回 \"pony\".');" }, { - "text": "checkObj(\"pet\") should return \"kitten\".", - "testString": "assert(checkObj(\"pet\") === \"kitten\", 'checkObj(\"pet\") should return \"kitten\".');" + "text": "checkObj(\"pet\") 应该返回 \"kitten\".", + "testString": "assert(checkObj(\"pet\") === \"kitten\", 'checkObj(\"pet\") 应该返回 \"kitten\".');" }, { - "text": "checkObj(\"house\") should return \"Not Found\".", - "testString": "assert(checkObj(\"house\") === \"Not Found\", 'checkObj(\"house\") should return \"Not Found\".');" + "text": "checkObj(\"house\") 应该返回 \"Not Found\".", + "testString": "assert(checkObj(\"house\") === \"Not Found\", 'checkObj(\"house\") 应该返回 \"Not Found\".');" } ], "challengeType": 1, @@ -5390,16 +5390,16 @@ ], "tests": [ { - "text": "myMusic should be an array", - "testString": "assert(Array.isArray(myMusic), 'myMusic should be an array');" + "text": "myMusic 应该是一个数组。", + "testString": "assert(Array.isArray(myMusic), 'myMusic 应该是一个数组。');" }, { "text": "myMusic should have at least two elements", "testString": "assert(myMusic.length > 1, 'myMusic should have at least two elements');" }, { - "text": "myMusic[1] should be an object", - "testString": "assert(typeof myMusic[1] === 'object', 'myMusic[1] should be an object');" + "text": "myMusic[1] 应该是一个对象。", + "testString": "assert(typeof myMusic[1] === 'object', 'myMusic[1] 应该是一个对象。');" }, { "text": "myMusic[1] should have at least 4 properties", @@ -5422,8 +5422,8 @@ "testString": "assert(myMusic[1].hasOwnProperty('formats') && Array.isArray(myMusic[1].formats), 'myMusic[1] should contain a formats property which is an array');" }, { - "text": "formats 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, 'formats should be an array of strings with at least two elements');" + "text": "formats 应该是一个包含至少两个元素的字符串的数组。", + "testString": "assert(myMusic[1].formats.every(function(item) { return (typeof item === \"string\")}) && myMusic[1].formats.length > 1, 'formats 应该是一个包含至少两个元素的字符串的数组。');" } ], "challengeType": 1, @@ -5472,8 +5472,8 @@ ], "tests": [ { - "text": "gloveBoxContents should equal \"maps\"", - "testString": "assert(gloveBoxContents === \"maps\", 'gloveBoxContents should equal \"maps\"');" + "text": "gloveBoxContents 应该等于 \"maps\"", + "testString": "assert(gloveBoxContents === \"maps\", 'gloveBoxContents 应该等于 \"maps\"');" }, { "text": "Use dot and bracket notation to access myStorage", @@ -5532,8 +5532,8 @@ ], "tests": [ { - "text": "secondTree should equal \"pine\"", - "testString": "assert(secondTree === \"pine\", 'secondTree should equal \"pine\"');" + "text": "secondTree 应该等于 \"pine\"", + "testString": "assert(secondTree === \"pine\", 'secondTree 应该等于 \"pine\"');" }, { "text": "Use dot and bracket notation to access myPlants", @@ -5709,8 +5709,8 @@ "testString": "assert(code.match(/while/g), 'You should be using a while loop for this.');" }, { - "text": "myArray should equal [0,1,2,3,4].", - "testString": "assert.deepEqual(myArray, [0,1,2,3,4], 'myArray should equal [0,1,2,3,4].');" + "text": "myArray 应该等于 [0,1,2,3,4].", + "testString": "assert.deepEqual(myArray, [0,1,2,3,4], 'myArray 应该等于 [0,1,2,3,4].');" } ], "challengeType": 1, @@ -5760,8 +5760,8 @@ "testString": "assert(code.match(/for\\s*\\(/g).length > 1, 'You should be using a for loop for this.');" }, { - "text": "myArray should equal [1,2,3,4,5].", - "testString": "assert.deepEqual(myArray, [1,2,3,4,5], 'myArray should equal [1,2,3,4,5].');" + "text": "myArray 应该等于 [1,2,3,4,5].", + "testString": "assert.deepEqual(myArray, [1,2,3,4,5], 'myArray 应该等于 [1,2,3,4,5].');" } ], "challengeType": 1, @@ -5813,8 +5813,8 @@ "testString": "assert(code.match(/for\\s*\\(/g).length > 1, 'You should be using a for loop for this.');" }, { - "text": "myArray should equal [1,3,5,7,9].", - "testString": "assert.deepEqual(myArray, [1,3,5,7,9], 'myArray should equal [1,3,5,7,9].');" + "text": "myArray 应该等于 [1,3,5,7,9].", + "testString": "assert.deepEqual(myArray, [1,3,5,7,9], 'myArray 应该等于 [1,3,5,7,9].');" } ], "challengeType": 1, @@ -5871,8 +5871,8 @@ "testString": "assert(code.match(/myArray.push/), 'You should be using the array method push.');" }, { - "text": "myArray should equal [9,7,5,3,1].", - "testString": "assert.deepEqual(myArray, [9,7,5,3,1], 'myArray should equal [9,7,5,3,1].');" + "text": "myArray 应该等于 [9,7,5,3,1].", + "testString": "assert.deepEqual(myArray, [9,7,5,3,1], 'myArray 应该等于 [9,7,5,3,1].');" } ], "challengeType": 1, @@ -5923,8 +5923,8 @@ "testString": "assert(code.match(/var.*?total\\s*=\\s*0.*?;/), 'total should be declared and initialized to 0');" }, { - "text": "total should equal 20", - "testString": "assert(total === 20, 'total should equal 20');" + "text": "total 应该等于 20", + "testString": "assert(total === 20, 'total 应该等于 20');" }, { "text": "You should use a for loop to iterate through myArr", @@ -5980,16 +5980,16 @@ ], "tests": [ { - "text": "multiplyAll([[1],[2],[3]]) should return 6", - "testString": "assert(multiplyAll([[1],[2],[3]]) === 6, 'multiplyAll([[1],[2],[3]]) should return 6');" + "text": "multiplyAll([[1],[2],[3]]) 应该返回 6", + "testString": "assert(multiplyAll([[1],[2],[3]]) === 6, 'multiplyAll([[1],[2],[3]]) 应该返回 6');" }, { - "text": "multiplyAll([[1,2],[3,4],[5,6,7]]) should return 5040", - "testString": "assert(multiplyAll([[1,2],[3,4],[5,6,7]]) === 5040, 'multiplyAll([[1,2],[3,4],[5,6,7]]) should return 5040');" + "text": "multiplyAll([[1,2],[3,4],[5,6,7]]) 应该返回 5040", + "testString": "assert(multiplyAll([[1,2],[3,4],[5,6,7]]) === 5040, 'multiplyAll([[1,2],[3,4],[5,6,7]]) 应该返回 5040');" }, { - "text": "multiplyAll([[5,1],[0.2, 4, 0.5],[3, 9]]) should return 54", - "testString": "assert(multiplyAll([[5,1],[0.2, 4, 0.5],[3, 9]]) === 54, 'multiplyAll([[5,1],[0.2, 4, 0.5],[3, 9]]) should return 54');" + "text": "multiplyAll([[5,1],[0.2, 4, 0.5],[3, 9]]) 应该返回 54", + "testString": "assert(multiplyAll([[5,1],[0.2, 4, 0.5],[3, 9]]) === 54, 'multiplyAll([[5,1],[0.2, 4, 0.5],[3, 9]]) 应该返回 54');" } ], "challengeType": 1, @@ -6044,12 +6044,12 @@ "testString": "assert(code.match(/do/g), 'You should be using a do...while loop for this.');" }, { - "text": "myArray should equal [10].", - "testString": "assert.deepEqual(myArray, [10], 'myArray should equal [10].');" + "text": "myArray 应该等于 [10].", + "testString": "assert.deepEqual(myArray, [10], 'myArray 应该等于 [10].');" }, { - "text": "i should equal 11", - "testString": "assert.deepEqual(i, 11, 'i should equal 11');" + "text": "i 应该等于 11", + "testString": "assert.deepEqual(i, 11, 'i 应该等于 11');" } ], "challengeType": 1, @@ -6095,28 +6095,28 @@ ], "tests": [ { - "text": "\"Kristian\", \"lastName\" should return \"Vos\"", - "testString": "assert(lookUpProfile('Kristian','lastName') === \"Vos\", '\"Kristian\", \"lastName\" should return \"Vos\"');" + "text": "\"Kristian\", \"lastName\" 应该返回 \"Vos\"", + "testString": "assert(lookUpProfile('Kristian','lastName') === \"Vos\", '\"Kristian\", \"lastName\" 应该返回 \"Vos\"');" }, { - "text": "\"Sherlock\", \"likes\" should return [\"Intriguing Cases\", \"Violin\"]", - "testString": "assert.deepEqual(lookUpProfile(\"Sherlock\", \"likes\"), [\"Intriguing Cases\", \"Violin\"], '\"Sherlock\", \"likes\" should return [\"Intriguing Cases\", \"Violin\"]');" + "text": "\"Sherlock\", \"likes\" 应该返回 [\"Intriguing Cases\", \"Violin\"]", + "testString": "assert.deepEqual(lookUpProfile(\"Sherlock\", \"likes\"), [\"Intriguing Cases\", \"Violin\"], '\"Sherlock\", \"likes\" 应该返回 [\"Intriguing Cases\", \"Violin\"]');" }, { - "text": "\"Harry\",\"likes\" should return an array", - "testString": "assert(typeof lookUpProfile(\"Harry\", \"likes\") === \"object\", '\"Harry\",\"likes\" should return an array');" + "text": "\"Harry\",\"likes\" 应该返回 an array", + "testString": "assert(typeof lookUpProfile(\"Harry\", \"likes\") === \"object\", '\"Harry\",\"likes\" 应该返回 an array');" }, { - "text": "\"Bob\", \"number\" should return \"No such contact\"", - "testString": "assert(lookUpProfile(\"Bob\", \"number\") === \"No such contact\", '\"Bob\", \"number\" should return \"No such contact\"');" + "text": "\"Bob\", \"number\" 应该返回 \"No such contact\"", + "testString": "assert(lookUpProfile(\"Bob\", \"number\") === \"No such contact\", '\"Bob\", \"number\" 应该返回 \"No such contact\"');" }, { - "text": "\"Bob\", \"potato\" should return \"No such contact\"", - "testString": "assert(lookUpProfile(\"Bob\", \"potato\") === \"No such contact\", '\"Bob\", \"potato\" should return \"No such contact\"');" + "text": "\"Bob\", \"potato\" 应该返回 \"No such contact\"", + "testString": "assert(lookUpProfile(\"Bob\", \"potato\") === \"No such contact\", '\"Bob\", \"potato\" 应该返回 \"No such contact\"');" }, { - "text": "\"Akira\", \"address\" should return \"No such property\"", - "testString": "assert(lookUpProfile(\"Akira\", \"address\") === \"No such property\", '\"Akira\", \"address\" should return \"No such property\"');" + "text": "\"Akira\", \"address\" 应该返回 \"No such property\"", + "testString": "assert(lookUpProfile(\"Akira\", \"address\") === \"No such property\", '\"Akira\", \"address\" 应该返回 \"No such property\"');" } ], "challengeType": 1, @@ -6184,8 +6184,8 @@ ], "tests": [ { - "text": "randomFraction should return a random number.", - "testString": "assert(typeof randomFraction() === \"number\", 'randomFraction should return a random number.');" + "text": "randomFraction 应该返回 a random number.", + "testString": "assert(typeof randomFraction() === \"number\", 'randomFraction 应该返回 a random number.');" }, { "text": "The number returned by randomFraction should be a decimal.", @@ -6371,20 +6371,20 @@ "testString": "assert(/parseInt/g.test(code), 'convertToInteger should use the parseInt() function');" }, { - "text": "convertToInteger(\"56\") should return a number", - "testString": "assert(typeof(convertToInteger(\"56\")) === \"number\", 'convertToInteger(\"56\") should return a number');" + "text": "convertToInteger(\"56\") 应该返回一个数字", + "testString": "assert(typeof(convertToInteger(\"56\")) === \"number\", 'convertToInteger(\"56\") 应该返回一个数字');" }, { - "text": "convertToInteger(\"56\") should return 56", - "testString": "assert(convertToInteger(\"56\") === 56, 'convertToInteger(\"56\") should return 56');" + "text": "convertToInteger(\"56\") 应该返回 56", + "testString": "assert(convertToInteger(\"56\") === 56, 'convertToInteger(\"56\") 应该返回 56');" }, { - "text": "convertToInteger(\"77\") should return 77", - "testString": "assert(convertToInteger(\"77\") === 77, 'convertToInteger(\"77\") should return 77');" + "text": "convertToInteger(\"77\") 应该返回 77", + "testString": "assert(convertToInteger(\"77\") === 77, 'convertToInteger(\"77\") 应该返回 77');" }, { - "text": "convertToInteger(\"JamesBond\") should return NaN", - "testString": "assert.isNaN(convertToInteger(\"JamesBond\"), 'convertToInteger(\"JamesBond\") should return NaN');" + "text": "convertToInteger(\"JamesBond\") 应该返回 NaN", + "testString": "assert.isNaN(convertToInteger(\"JamesBond\"), 'convertToInteger(\"JamesBond\") 应该返回 NaN');" } ], "challengeType": 1, @@ -6426,20 +6426,20 @@ "testString": "assert(/parseInt/g.test(code), 'convertToInteger should use the parseInt() function');" }, { - "text": "convertToInteger(\"10011\") should return a number", - "testString": "assert(typeof(convertToInteger(\"10011\")) === \"number\", 'convertToInteger(\"10011\") should return a number');" + "text": "convertToInteger(\"10011\") 应该返回一个数字", + "testString": "assert(typeof(convertToInteger(\"10011\")) === \"number\", 'convertToInteger(\"10011\") 应该返回一个数字');" }, { - "text": "convertToInteger(\"10011\") should return 19", - "testString": "assert(convertToInteger(\"10011\") === 19, 'convertToInteger(\"10011\") should return 19');" + "text": "convertToInteger(\"10011\") 应该返回 19", + "testString": "assert(convertToInteger(\"10011\") === 19, 'convertToInteger(\"10011\") 应该返回 19');" }, { - "text": "convertToInteger(\"111001\") should return 57", - "testString": "assert(convertToInteger(\"111001\") === 57, 'convertToInteger(\"111001\") should return 57');" + "text": "convertToInteger(\"111001\") 应该返回 57", + "testString": "assert(convertToInteger(\"111001\") === 57, 'convertToInteger(\"111001\") 应该返回 57');" }, { - "text": "convertToInteger(\"JamesBond\") should return NaN", - "testString": "assert.isNaN(convertToInteger(\"JamesBond\"), 'convertToInteger(\"JamesBond\") should return NaN');" + "text": "convertToInteger(\"JamesBond\") 应该返回 NaN", + "testString": "assert.isNaN(convertToInteger(\"JamesBond\"), 'convertToInteger(\"JamesBond\") 应该返回 NaN');" } ], "challengeType": 1, @@ -6473,7 +6473,7 @@ "This can be re-written using the conditional operator:", "
function findGreater(a, b) {
  return a > b ? \"a is greater\" : \"b is greater\";
}
", "
", - "Use the conditional operator in the checkEqual function to check if two numbers are equal or not. The function should return either true or false." + "Use the conditional operator in the checkEqual function to check if two numbers are equal or not. The function 应该返回 either true or false." ], "solutions": [], "tests": [ @@ -6482,16 +6482,16 @@ "testString": "assert(/.+?\\s*?\\?\\s*?.+?\\s*?:\\s*?.+?/gi.test(code), 'checkEqual should use the conditional operator');" }, { - "text": "checkEqual(1, 2) should return false", - "testString": "assert(checkEqual(1, 2) === false, 'checkEqual(1, 2) should return false');" + "text": "checkEqual(1, 2) 应该返回 false", + "testString": "assert(checkEqual(1, 2) === false, 'checkEqual(1, 2) 应该返回 false');" }, { - "text": "checkEqual(1, 1) should return true", - "testString": "assert(checkEqual(1, 1) === true, 'checkEqual(1, 1) should return true');" + "text": "checkEqual(1, 1) 应该返回 true", + "testString": "assert(checkEqual(1, 1) === true, 'checkEqual(1, 1) 应该返回 true');" }, { - "text": "checkEqual(1, -1) should return false", - "testString": "assert(checkEqual(1, -1) === false, 'checkEqual(1, -1) should return false');" + "text": "checkEqual(1, -1) 应该返回 false", + "testString": "assert(checkEqual(1, -1) === false, 'checkEqual(1, -1) 应该返回 false');" } ], "challengeType": 1, @@ -6532,16 +6532,16 @@ "testString": "assert(/.+?\\s*?\\?\\s*?.+?\\s*?:\\s*?.+?\\s*?\\?\\s*?.+?\\s*?:\\s*?.+?/gi.test(code), 'checkSign should use multiple conditional operators');" }, { - "text": "checkSign(10) should return \"positive\". Note that capitalization matters", - "testString": "assert(checkSign(10) === 'positive', 'checkSign(10) should return \"positive\". Note that capitalization matters');" + "text": "checkSign(10) 应该返回 \"positive\". Note that capitalization matters", + "testString": "assert(checkSign(10) === 'positive', 'checkSign(10) 应该返回 \"positive\". Note that capitalization matters');" }, { - "text": "checkSign(-12) should return \"negative\". Note that capitalization matters", - "testString": "assert(checkSign(-12) === 'negative', 'checkSign(-12) should return \"negative\". Note that capitalization matters');" + "text": "checkSign(-12) 应该返回 \"negative\". Note that capitalization matters", + "testString": "assert(checkSign(-12) === 'negative', 'checkSign(-12) 应该返回 \"negative\". Note that capitalization matters');" }, { - "text": "checkSign(0) should return \"zero\". Note that capitalization matters", - "testString": "assert(checkSign(0) === 'zero', 'checkSign(0) should return \"zero\". Note that capitalization matters');" + "text": "checkSign(0) 应该返回 \"zero\". Note that capitalization matters", + "testString": "assert(checkSign(0) === 'zero', 'checkSign(0) 应该返回 \"zero\". Note that capitalization matters');" } ], "challengeType": 1, @@ -6564,4 +6564,4 @@ } } ] -} \ No newline at end of file +}