element has a closing tag.",
+ "testString": "assert(code.match(/<\\/div>/g) && code.match(/<\\/div>/g).length === code.match(/
/g).length, 'Make sure your
div
element has a closing tag.');"
}
],
"challengeType": 0,
@@ -1382,26 +1382,26 @@
"description": [
"The challenges so far have covered specific HTML tags and their uses. However, there are a few elements that give overall structure to your page, and should be included in every HTML document.",
"At the top of your document, you need to tell the browser which version of HTML your page is using. HTML is an evolving language, and is updated regularly. Most major browsers support the latest specification, which is HTML5. However, older web pages may use previous versions of the language.",
- "You tell the browser this information by adding the
<!DOCTYPE ...>
tag on the first line, where the \"
...
\" part is the version of HTML. For HTML5, you use
<!DOCTYPE html>
.",
- "The
!
and uppercase
DOCTYPE
is important, especially for older browsers. The
html
is not case sensitive.",
- "Next, the rest of your HTML code needs to be wrapped in
html
tags. The opening
<html>
goes directly below the
<!DOCTYPE html>
line, and the closing
</html>
goes at the end of the page.",
+ "You tell the browser this information by adding the
<!DOCTYPE ...>
tag on the first line, where the \"
...
\" part is the version of HTML. For HTML5, you use
<!DOCTYPE html>
.",
+ "The
!
and uppercase
DOCTYPE
is important, especially for older browsers. The
html
is not case sensitive.",
+ "Next, the rest of your HTML code needs to be wrapped in
html
tags. The opening
<html>
goes directly below the
<!DOCTYPE html>
line, and the closing
</html>
goes at the end of the page.",
"Here's an example of the page structure:",
"
<!DOCTYPE html>
<html>
<!-- Your HTML code goes here -->
</html>
",
"
",
- "Add a
DOCTYPE
tag for HTML5 to the top of the blank HTML document in the code editor. Under it, add opening and closing
html
tags, which wrap around an
h1
element. The heading can include any text."
+ "Add a
DOCTYPE
tag for HTML5 to the top of the blank HTML document in the code editor. Under it, add opening and closing
html
tags, which wrap around an
h1
element. The heading can include any text."
],
"tests": [
{
- "text": "Your code should include a
<!DOCTYPE html>
tag.",
- "testString": "assert(code.match(//gi), 'Your code should include a
<!DOCTYPE html>
tag.');"
+ "text": "Your code should include a
<!DOCTYPE html>
tag.",
+ "testString": "assert(code.match(//gi), 'Your code should include a
<!DOCTYPE html>
tag.');"
},
{
- "text": "There should be one
html
element.",
- "testString": "assert($('html').length == 1, 'There should be one
html
element.');"
+ "text": "There should be one
html
element.",
+ "testString": "assert($('html').length == 1, 'There should be one
html
element.');"
},
{
- "text": "The
html
tags should wrap around one
h1
element.",
- "testString": "assert(code.match(/\\s*?
\\s*?.*?\\s*?<\\/h1>\\s*?<\\/html>/gi), 'The html
tags should wrap around one h1
element.');"
+ "text": "Thehtml
tags should wrap around oneh1
element.",
+ "testString": "assert(code.match(/\\s*?\\s*?.*?\\s*?<\\/h1>\\s*?<\\/html>/gi), 'Thehtml
tags should wrap around oneh1
element.');"
}
],
"challengeType": 0,
@@ -1420,37 +1420,37 @@
"id": "587d78aa367417b2b2512aec",
"title": "Define the Head and Body of an HTML Document",
"description": [
- "You can add another level of organization in your HTML document within the html
tags with the head
and body
elements. Any markup with information about your page would go into the head
tag. Then any markup with the content of the page (what displays for a user) would go into the body
tag.",
- "Metadata elements, such as link
, meta
, title
, and style
, typically go inside the head
element.",
+ "You can add another level of organization in your HTML document within thehtml
tags with thehead
andbody
elements. Any markup with information about your page would go into thehead
tag. Then any markup with the content of the page (what displays for a user) would go into thebody
tag.",
+ "Metadata elements, such aslink
,meta
,title
, andstyle
, typically go inside thehead
element.",
"Here's an example of a page's layout:",
"<!DOCTYPE html>
<html>
<head>
<!-- metadata elements -->
</head>
<body>
<!-- page contents -->
</body>
</html>
",
"
",
- "Edit the markup so there's a head
and a body
. The head
element should only include the title
, and the body
element should only include the h1
and p
."
+ "Edit the markup so there's ahead
and abody
. Thehead
element should only include thetitle
, and thebody
element should only include theh1
andp
."
],
"tests": [
{
- "text": "There should be only one head
element on the page.",
- "testString": "assert($('head').length == 1, 'There should be only one head
element on the page.');"
+ "text": "There should be only onehead
element on the page.",
+ "testString": "assert($('head').length == 1, 'There should be only onehead
element on the page.');"
},
{
- "text": "There should be only one body
element on the page.",
- "testString": "assert($('body').length == 1, 'There should be only one body
element on the page.');"
+ "text": "There should be only onebody
element on the page.",
+ "testString": "assert($('body').length == 1, 'There should be only onebody
element on the page.');"
},
{
- "text": "The head
element should be a child of the html
element.",
- "testString": "assert($('html').children('head').length == 1, 'The head
element should be a child of the html
element.');"
+ "text": "Thehead
element should be a child of thehtml
element.",
+ "testString": "assert($('html').children('head').length == 1, 'Thehead
element should be a child of thehtml
element.');"
},
{
- "text": "The body
element should be a child of the html
element.",
- "testString": "assert($('html').children('body').length == 1, 'The body
element should be a child of the html
element.');"
+ "text": "Thebody
element should be a child of thehtml
element.",
+ "testString": "assert($('html').children('body').length == 1, 'Thebody
element should be a child of thehtml
element.');"
},
{
- "text": "The head
element should wrap around the title
element.",
- "testString": "assert(code.match(/\\s*?\\s*?.*?\\s*?<\\/title>\\s*?<\\/head>/gi), 'The head
element should wrap around the title
element.');"
+ "text": "Thehead
element should wrap around thetitle
element.",
+ "testString": "assert(code.match(/\\s*?\\s*?.*?\\s*?<\\/title>\\s*?<\\/head>/gi), 'Thehead
element should wrap around thetitle
element.');"
},
{
- "text": "The body
element should wrap around both the h1
and p
elements.",
- "testString": "assert($('body').children('h1').length == 1 && $('body').children('p').length == 1, 'The body
element should wrap around both the h1
and p
elements.');"
+ "text": "Thebody
element should wrap around both theh1
andp
elements.",
+ "testString": "assert($('body').children('h1').length == 1 && $('body').children('p').length == 1, 'Thebody
element should wrap around both theh1
andp
elements.');"
}
],
"challengeType": 0,
@@ -1465,7 +1465,7 @@
" The best page ever",
" ",
" The best page ever
",
- " 在大家心目中,猫是慵懒和可爱的化身,它可以睡饱了再起来吃饭,可以逗趣小耗子,可以卖得了萌,使得了坏,这样百变的小怪兽就集结在一只宠物上,怎能不惹人怜爱。 在大家心目中,猫是慵懒和可爱的化身,它可以睡饱了再起来吃饭,可以逗趣小耗子,可以卖得了萌,使得了坏,这样百变的小怪兽就集结在一只宠物上,怎能不惹人怜爱。
",
+ " 在大家心目中,猫是慵懒和可爱的化身,它可以睡饱了再起来吃饭,可以逗趣小耗子,可以卖得了萌,使得了坏,这样百变的小怪兽就集结在一只宠物上,怎能不惹人怜爱。在大家心目中,猫是慵懒和可爱的化身,它可以睡饱了再起来吃饭,可以逗趣小耗子,可以卖得了萌,使得了坏,这样百变的小怪兽就集结在一只宠物上,怎能不惹人怜爱。
",
" ",
" "
],
@@ -1475,4 +1475,4 @@
}
}
]
-}
\ No newline at end of file
+}
diff --git a/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting.json b/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting.json
index 53827f4..74e40ca 100644
--- a/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting.json
+++ b/02-javascript-algorithms-and-data-structures/intermediate-algorithm-scripting.json
@@ -10,11 +10,11 @@
"description": [
"给出一个含有两个数字的数组,我们需要写一个函数,让它返回这两个数字间所有数字(包含这两个数字)的总和。",
"注意,较小数不一定总是出现在数组的第一个元素。",
- "如果你遇到了问题,请点击 帮助。"
+ "如果你遇到了问题,请点击帮助。"
],
"hints": [
- "使用 Math.max()
来获取两数中较大的数。",
- "使用 Math.min()
来获取两数中较小的数。",
+ "使用Math.max()
来获取两数中较大的数。",
+ "使用Math.min()
来获取两数中较小的数。",
"注意,既然需要对两数之间的所有数求和,那就先要考虑好如何获取这些数。"
],
"solutions": [
@@ -22,24 +22,24 @@
],
"tests": [
{
- "text": "sumAll([1, 4])
应该返回一个数字。",
- "testString": "assert(typeof sumAll([1, 4]) === 'number', 'sumAll([1, 4])
应该返回一个数字。');"
+ "text": "sumAll([1, 4])
应该返回一个数字。",
+ "testString": "assert(typeof sumAll([1, 4]) === 'number', 'sumAll([1, 4])
应该返回一个数字。');"
},
{
- "text": "sumAll([1, 4])
应该返回 10。",
- "testString": "assert.deepEqual(sumAll([1, 4]), 10, 'sumAll([1, 4])
应该返回 10。');"
+ "text": "sumAll([1, 4])
应该返回 10。",
+ "testString": "assert.deepEqual(sumAll([1, 4]), 10, 'sumAll([1, 4])
应该返回 10。');"
},
{
- "text": "sumAll([4, 1])
应该返回 10。",
- "testString": "assert.deepEqual(sumAll([4, 1]), 10, 'sumAll([4, 1])
应该返回 10。');"
+ "text": "sumAll([4, 1])
应该返回 10。",
+ "testString": "assert.deepEqual(sumAll([4, 1]), 10, 'sumAll([4, 1])
应该返回 10。');"
},
{
- "text": "sumAll([5, 10])
应该返回 45。",
- "testString": "assert.deepEqual(sumAll([5, 10]), 45, 'sumAll([5, 10])
应该返回 45。');"
+ "text": "sumAll([5, 10])
应该返回 45。",
+ "testString": "assert.deepEqual(sumAll([5, 10]), 45, 'sumAll([5, 10])
应该返回 45。');"
},
{
- "text": "sumAll([10, 5])
应该返回 45。",
- "testString": "assert.deepEqual(sumAll([10, 5]), 45, 'sumAll([10, 5])
应该返回 45。');"
+ "text": "sumAll([10, 5])
应该返回 45。",
+ "testString": "assert.deepEqual(sumAll([10, 5]), 45, 'sumAll([10, 5])
应该返回 45。');"
}
],
"MDNlinks": [
@@ -71,7 +71,7 @@
"title": "Diff Two Arrays",
"description": [
"在这道题目中,我们需要写一个函数,比较两个数组,返回一个新的数组。这个新数组需要包含传入的两个数组所有元素中,仅在其中一个数组里出现的元素。如果某个元素同时出现在两个数组中,则不应包含在返回的数组里。换言之,我们需要返回这两个数组的对称差。",
- "如果你遇到了问题,请点击 帮助。",
+ "如果你遇到了问题,请点击帮助。",
"注意:
返回数组中的元素顺序不会影响测试结果。"
],
"solutions": [
@@ -79,64 +79,64 @@
],
"tests": [
{
- "text": "diffArray([1, 2, 3, 5], [1, 2, 3, 4, 5])
应该返回一个数组。",
- "testString": "assert(typeof diffArray([1, 2, 3, 5], [1, 2, 3, 4, 5]) === \"object\", 'diffArray([1, 2, 3, 5], [1, 2, 3, 4, 5])
应该返回一个数组。');"
+ "text": "diffArray([1, 2, 3, 5], [1, 2, 3, 4, 5])
应该返回一个数组。",
+ "testString": "assert(typeof diffArray([1, 2, 3, 5], [1, 2, 3, 4, 5]) === \"object\", 'diffArray([1, 2, 3, 5], [1, 2, 3, 4, 5])
应该返回一个数组。');"
},
{
- "text": "[\"diorite\", \"andesite\", \"grass\", \"dirt\", \"pink wool\", \"dead shrub\"], [\"diorite\", \"andesite\", \"grass\", \"dirt\", \"dead shrub\"]
应该返回 [\"pink wool\"]
。",
- "testString": "assert.sameMembers(diffArray([\"diorite\", \"andesite\", \"grass\", \"dirt\", \"pink wool\", \"dead shrub\"], [\"diorite\", \"andesite\", \"grass\", \"dirt\", \"dead shrub\"]), [\"pink wool\"], '[\"diorite\", \"andesite\", \"grass\", \"dirt\", \"pink wool\", \"dead shrub\"], [\"diorite\", \"andesite\", \"grass\", \"dirt\", \"dead shrub\"]
应该返回 [\"pink wool\"]
。');"
+ "text": "[\"diorite\", \"andesite\", \"grass\", \"dirt\", \"pink wool\", \"dead shrub\"], [\"diorite\", \"andesite\", \"grass\", \"dirt\", \"dead shrub\"]
应该返回[\"pink wool\"]
。",
+ "testString": "assert.sameMembers(diffArray([\"diorite\", \"andesite\", \"grass\", \"dirt\", \"pink wool\", \"dead shrub\"], [\"diorite\", \"andesite\", \"grass\", \"dirt\", \"dead shrub\"]), [\"pink wool\"], '[\"diorite\", \"andesite\", \"grass\", \"dirt\", \"pink wool\", \"dead shrub\"], [\"diorite\", \"andesite\", \"grass\", \"dirt\", \"dead shrub\"]
应该返回[\"pink wool\"]
。');"
},
{
- "text": "[\"diorite\", \"andesite\", \"grass\", \"dirt\", \"pink wool\", \"dead shrub\"], [\"diorite\", \"andesite\", \"grass\", \"dirt\", \"dead shrub\"]
应该返回一个长度为 1 的数组。",
- "testString": "assert(diffArray([\"diorite\", \"andesite\", \"grass\", \"dirt\", \"pink wool\", \"dead shrub\"], [\"diorite\", \"andesite\", \"grass\", \"dirt\", \"dead shrub\"]).length === 1, '[\"diorite\", \"andesite\", \"grass\", \"dirt\", \"pink wool\", \"dead shrub\"], [\"diorite\", \"andesite\", \"grass\", \"dirt\", \"dead shrub\"]
应该返回一个长度为 1 的数组。');"
+ "text": "[\"diorite\", \"andesite\", \"grass\", \"dirt\", \"pink wool\", \"dead shrub\"], [\"diorite\", \"andesite\", \"grass\", \"dirt\", \"dead shrub\"]
应该返回一个长度为 1 的数组。",
+ "testString": "assert(diffArray([\"diorite\", \"andesite\", \"grass\", \"dirt\", \"pink wool\", \"dead shrub\"], [\"diorite\", \"andesite\", \"grass\", \"dirt\", \"dead shrub\"]).length === 1, '[\"diorite\", \"andesite\", \"grass\", \"dirt\", \"pink wool\", \"dead shrub\"], [\"diorite\", \"andesite\", \"grass\", \"dirt\", \"dead shrub\"]
应该返回一个长度为 1 的数组。');"
},
{
- "text": "[\"andesite\", \"grass\", \"dirt\", \"pink wool\", \"dead shrub\"], [\"diorite\", \"andesite\", \"grass\", \"dirt\", \"dead shrub\"]
应该返回 [\"diorite\", \"pink wool\"]
。",
- "testString": "assert.sameMembers(diffArray([\"andesite\", \"grass\", \"dirt\", \"pink wool\", \"dead shrub\"], [\"diorite\", \"andesite\", \"grass\", \"dirt\", \"dead shrub\"]), [\"diorite\", \"pink wool\"], '[\"andesite\", \"grass\", \"dirt\", \"pink wool\", \"dead shrub\"], [\"diorite\", \"andesite\", \"grass\", \"dirt\", \"dead shrub\"]
应该返回 [\"diorite\", \"pink wool\"]
。');"
+ "text": "[\"andesite\", \"grass\", \"dirt\", \"pink wool\", \"dead shrub\"], [\"diorite\", \"andesite\", \"grass\", \"dirt\", \"dead shrub\"]
应该返回[\"diorite\", \"pink wool\"]
。",
+ "testString": "assert.sameMembers(diffArray([\"andesite\", \"grass\", \"dirt\", \"pink wool\", \"dead shrub\"], [\"diorite\", \"andesite\", \"grass\", \"dirt\", \"dead shrub\"]), [\"diorite\", \"pink wool\"], '[\"andesite\", \"grass\", \"dirt\", \"pink wool\", \"dead shrub\"], [\"diorite\", \"andesite\", \"grass\", \"dirt\", \"dead shrub\"]
应该返回[\"diorite\", \"pink wool\"]
。');"
},
{
- "text": "[\"andesite\", \"grass\", \"dirt\", \"pink wool\", \"dead shrub\"], [\"diorite\", \"andesite\", \"grass\", \"dirt\", \"dead shrub\"]
应该返回一个长度为 2 的数组。",
- "testString": "assert(diffArray([\"andesite\", \"grass\", \"dirt\", \"pink wool\", \"dead shrub\"], [\"diorite\", \"andesite\", \"grass\", \"dirt\", \"dead shrub\"]).length === 2, '[\"andesite\", \"grass\", \"dirt\", \"pink wool\", \"dead shrub\"], [\"diorite\", \"andesite\", \"grass\", \"dirt\", \"dead shrub\"]
应该返回一个长度为 2 的数组。');"
+ "text": "[\"andesite\", \"grass\", \"dirt\", \"pink wool\", \"dead shrub\"], [\"diorite\", \"andesite\", \"grass\", \"dirt\", \"dead shrub\"]
应该返回一个长度为 2 的数组。",
+ "testString": "assert(diffArray([\"andesite\", \"grass\", \"dirt\", \"pink wool\", \"dead shrub\"], [\"diorite\", \"andesite\", \"grass\", \"dirt\", \"dead shrub\"]).length === 2, '[\"andesite\", \"grass\", \"dirt\", \"pink wool\", \"dead shrub\"], [\"diorite\", \"andesite\", \"grass\", \"dirt\", \"dead shrub\"]
应该返回一个长度为 2 的数组。');"
},
{
- "text": "[\"andesite\", \"grass\", \"dirt\", \"dead shrub\"], [\"andesite\", \"grass\", \"dirt\", \"dead shrub\"]
应该返回 []
。",
- "testString": "assert.sameMembers(diffArray([\"andesite\", \"grass\", \"dirt\", \"dead shrub\"], [\"andesite\", \"grass\", \"dirt\", \"dead shrub\"]), [], '[\"andesite\", \"grass\", \"dirt\", \"dead shrub\"], [\"andesite\", \"grass\", \"dirt\", \"dead shrub\"]
应该返回 []
。');"
+ "text": "[\"andesite\", \"grass\", \"dirt\", \"dead shrub\"], [\"andesite\", \"grass\", \"dirt\", \"dead shrub\"]
应该返回[]
。",
+ "testString": "assert.sameMembers(diffArray([\"andesite\", \"grass\", \"dirt\", \"dead shrub\"], [\"andesite\", \"grass\", \"dirt\", \"dead shrub\"]), [], '[\"andesite\", \"grass\", \"dirt\", \"dead shrub\"], [\"andesite\", \"grass\", \"dirt\", \"dead shrub\"]
应该返回[]
。');"
},
{
- "text": "[\"andesite\", \"grass\", \"dirt\", \"dead shrub\"], [\"andesite\", \"grass\", \"dirt\", \"dead shrub\"]
应该返回一个空数组。",
- "testString": "assert(diffArray([\"andesite\", \"grass\", \"dirt\", \"dead shrub\"], [\"andesite\", \"grass\", \"dirt\", \"dead shrub\"]).length === 0, '[\"andesite\", \"grass\", \"dirt\", \"dead shrub\"], [\"andesite\", \"grass\", \"dirt\", \"dead shrub\"]
应该返回一个空数组。');"
+ "text": "[\"andesite\", \"grass\", \"dirt\", \"dead shrub\"], [\"andesite\", \"grass\", \"dirt\", \"dead shrub\"]
应该返回一个空数组。",
+ "testString": "assert(diffArray([\"andesite\", \"grass\", \"dirt\", \"dead shrub\"], [\"andesite\", \"grass\", \"dirt\", \"dead shrub\"]).length === 0, '[\"andesite\", \"grass\", \"dirt\", \"dead shrub\"], [\"andesite\", \"grass\", \"dirt\", \"dead shrub\"]
应该返回一个空数组。');"
},
{
- "text": "[1, 2, 3, 5], [1, 2, 3, 4, 5]
应该返回 [4]
。",
- "testString": "assert.sameMembers(diffArray([1, 2, 3, 5], [1, 2, 3, 4, 5]), [4], '[1, 2, 3, 5], [1, 2, 3, 4, 5]
应该返回 [4]
。');"
+ "text": "[1, 2, 3, 5], [1, 2, 3, 4, 5]
应该返回[4]
。",
+ "testString": "assert.sameMembers(diffArray([1, 2, 3, 5], [1, 2, 3, 4, 5]), [4], '[1, 2, 3, 5], [1, 2, 3, 4, 5]
应该返回[4]
。');"
},
{
- "text": "[1, 2, 3, 5], [1, 2, 3, 4, 5]
应该返回一个长度为 1 的数组。",
- "testString": "assert(diffArray([1, 2, 3, 5], [1, 2, 3, 4, 5]).length === 1, '[1, 2, 3, 5], [1, 2, 3, 4, 5]
应该返回一个长度为 1 的数组。');"
+ "text": "[1, 2, 3, 5], [1, 2, 3, 4, 5]
应该返回一个长度为 1 的数组。",
+ "testString": "assert(diffArray([1, 2, 3, 5], [1, 2, 3, 4, 5]).length === 1, '[1, 2, 3, 5], [1, 2, 3, 4, 5]
应该返回一个长度为 1 的数组。');"
},
{
- "text": "[1, \"calf\", 3, \"piglet\"], [1, \"calf\", 3, 4]
应该返回 [\"piglet\", 4]
。",
- "testString": "assert.sameMembers(diffArray([1, \"calf\", 3, \"piglet\"], [1, \"calf\", 3, 4]), [\"piglet\", 4], '[1, \"calf\", 3, \"piglet\"], [1, \"calf\", 3, 4]
应该返回 [\"piglet\", 4]
。');"
+ "text": "[1, \"calf\", 3, \"piglet\"], [1, \"calf\", 3, 4]
应该返回[\"piglet\", 4]
。",
+ "testString": "assert.sameMembers(diffArray([1, \"calf\", 3, \"piglet\"], [1, \"calf\", 3, 4]), [\"piglet\", 4], '[1, \"calf\", 3, \"piglet\"], [1, \"calf\", 3, 4]
应该返回[\"piglet\", 4]
。');"
},
{
- "text": "[1, \"calf\", 3, \"piglet\"], [1, \"calf\", 3, 4]
应该返回一个长度为 2 的数组。",
- "testString": "assert(diffArray([1, \"calf\", 3, \"piglet\"], [1, \"calf\", 3, 4]).length === 2, '[1, \"calf\", 3, \"piglet\"], [1, \"calf\", 3, 4]
应该返回一个长度为 2 的数组。');"
+ "text": "[1, \"calf\", 3, \"piglet\"], [1, \"calf\", 3, 4]
应该返回一个长度为 2 的数组。",
+ "testString": "assert(diffArray([1, \"calf\", 3, \"piglet\"], [1, \"calf\", 3, 4]).length === 2, '[1, \"calf\", 3, \"piglet\"], [1, \"calf\", 3, 4]
应该返回一个长度为 2 的数组。');"
},
{
- "text": "[], [\"snuffleupagus\", \"cookie monster\", \"elmo\"]
应该返回 [\"snuffleupagus\", \"cookie monster\", \"elmo\"]
。",
- "testString": "assert.sameMembers(diffArray([], [\"snuffleupagus\", \"cookie monster\", \"elmo\"]), [\"snuffleupagus\", \"cookie monster\", \"elmo\"], '[], [\"snuffleupagus\", \"cookie monster\", \"elmo\"]
应该返回 [\"snuffleupagus\", \"cookie monster\", \"elmo\"]
。');"
+ "text": "[], [\"snuffleupagus\", \"cookie monster\", \"elmo\"]
应该返回[\"snuffleupagus\", \"cookie monster\", \"elmo\"]
。",
+ "testString": "assert.sameMembers(diffArray([], [\"snuffleupagus\", \"cookie monster\", \"elmo\"]), [\"snuffleupagus\", \"cookie monster\", \"elmo\"], '[], [\"snuffleupagus\", \"cookie monster\", \"elmo\"]
应该返回[\"snuffleupagus\", \"cookie monster\", \"elmo\"]
。');"
},
{
- "text": "[], [\"snuffleupagus\", \"cookie monster\", \"elmo\"]
应该返回一个长度为 3 的数组。",
- "testString": "assert(diffArray([], [\"snuffleupagus\", \"cookie monster\", \"elmo\"]).length === 3, '[], [\"snuffleupagus\", \"cookie monster\", \"elmo\"]
应该返回一个长度为 3 的数组。');"
+ "text": "[], [\"snuffleupagus\", \"cookie monster\", \"elmo\"]
应该返回一个长度为 3 的数组。",
+ "testString": "assert(diffArray([], [\"snuffleupagus\", \"cookie monster\", \"elmo\"]).length === 3, '[], [\"snuffleupagus\", \"cookie monster\", \"elmo\"]
应该返回一个长度为 3 的数组。');"
},
{
- "text": "[1, \"calf\", 3, \"piglet\"], [7, \"filly\"]
应该返回 [1, \"calf\", 3, \"piglet\", 7, \"filly\"]
。",
- "testString": "assert.sameMembers(diffArray([1, \"calf\", 3, \"piglet\"], [7, \"filly\"]), [1, \"calf\", 3, \"piglet\", 7, \"filly\"], '[1, \"calf\", 3, \"piglet\"], [7, \"filly\"]
应该返回 [1, \"calf\", 3, \"piglet\", 7, \"filly\"]
。');"
+ "text": "[1, \"calf\", 3, \"piglet\"], [7, \"filly\"]
应该返回[1, \"calf\", 3, \"piglet\", 7, \"filly\"]
。",
+ "testString": "assert.sameMembers(diffArray([1, \"calf\", 3, \"piglet\"], [7, \"filly\"]), [1, \"calf\", 3, \"piglet\", 7, \"filly\"], '[1, \"calf\", 3, \"piglet\"], [7, \"filly\"]
应该返回[1, \"calf\", 3, \"piglet\", 7, \"filly\"]
。');"
},
{
- "text": "[1, \"calf\", 3, \"piglet\"], [7, \"filly\"]
应该返回一个长度为 6 的数组。",
- "testString": "assert(diffArray([1, \"calf\", 3, \"piglet\"], [7, \"filly\"]).length === 6, '[1, \"calf\", 3, \"piglet\"], [7, \"filly\"]
应该返回一个长度为 6 的数组。');"
+ "text": "[1, \"calf\", 3, \"piglet\"], [7, \"filly\"]
应该返回一个长度为 6 的数组。",
+ "testString": "assert(diffArray([1, \"calf\", 3, \"piglet\"], [7, \"filly\"]).length === 6, '[1, \"calf\", 3, \"piglet\"], [7, \"filly\"]
应该返回一个长度为 6 的数组。');"
}
],
"MDNlinks": [
@@ -171,34 +171,34 @@
"id": "a39963a4c10bc8b4d4f06d7e",
"title": "Seek and Destroy",
"description": [
- "在这道题目中,我们要写一个叫 destroyer
的函数。传给它的第一个参数是数组,我们称他为初始数组。后续的参数数量是不确定的,可能有一个或多个。你需要做的是,从初始数组中移除所有与后续参数相等的元素,并返回移除元素后的数组。",
- "注意:
你可以使用 arguments
对象,也可以使用 ...
,即“剩余参数”(Rest Parameters)语法。",
- "如果你遇到了问题,请点击 帮助。"
+ "在这道题目中,我们要写一个叫destroyer
的函数。传给它的第一个参数是数组,我们称他为初始数组。后续的参数数量是不确定的,可能有一个或多个。你需要做的是,从初始数组中移除所有与后续参数相等的元素,并返回移除元素后的数组。",
+ "注意:
你可以使用arguments
对象,也可以使用...
,即 “剩余参数”(Rest Parameters)语法。",
+ "如果你遇到了问题,请点击帮助。"
],
"tests": [
{
- "text": "destroyer([1, 2, 3, 1, 2, 3], 2, 3)
应该返回 [1, 1]
。",
- "testString": "assert.deepEqual(destroyer([1, 2, 3, 1, 2, 3], 2, 3), [1, 1], 'destroyer([1, 2, 3, 1, 2, 3], 2, 3)
应该返回 [1, 1]
。');"
+ "text": "destroyer([1, 2, 3, 1, 2, 3], 2, 3)
应该返回[1, 1]
。",
+ "testString": "assert.deepEqual(destroyer([1, 2, 3, 1, 2, 3], 2, 3), [1, 1], 'destroyer([1, 2, 3, 1, 2, 3], 2, 3)
应该返回[1, 1]
。');"
},
{
- "text": "destroyer([1, 2, 3, 5, 1, 2, 3], 2, 3)
应该返回 [1, 5, 1]
。",
- "testString": "assert.deepEqual(destroyer([1, 2, 3, 5, 1, 2, 3], 2, 3), [1, 5, 1], 'destroyer([1, 2, 3, 5, 1, 2, 3], 2, 3)
应该返回 [1, 5, 1]
。');"
+ "text": "destroyer([1, 2, 3, 5, 1, 2, 3], 2, 3)
应该返回[1, 5, 1]
。",
+ "testString": "assert.deepEqual(destroyer([1, 2, 3, 5, 1, 2, 3], 2, 3), [1, 5, 1], 'destroyer([1, 2, 3, 5, 1, 2, 3], 2, 3)
应该返回[1, 5, 1]
。');"
},
{
- "text": "destroyer([3, 5, 1, 2, 2], 2, 3, 5)
应该返回 [1]
。",
- "testString": "assert.deepEqual(destroyer([3, 5, 1, 2, 2], 2, 3, 5), [1], 'destroyer([3, 5, 1, 2, 2], 2, 3, 5)
应该返回 [1]
。');"
+ "text": "destroyer([3, 5, 1, 2, 2], 2, 3, 5)
应该返回[1]
。",
+ "testString": "assert.deepEqual(destroyer([3, 5, 1, 2, 2], 2, 3, 5), [1], 'destroyer([3, 5, 1, 2, 2], 2, 3, 5)
应该返回[1]
。');"
},
{
- "text": "destroyer([2, 3, 2, 3], 2, 3)
应该返回 []
。",
- "testString": "assert.deepEqual(destroyer([2, 3, 2, 3], 2, 3), [], 'destroyer([2, 3, 2, 3], 2, 3)
应该返回 []
。');"
+ "text": "destroyer([2, 3, 2, 3], 2, 3)
应该返回[]
。",
+ "testString": "assert.deepEqual(destroyer([2, 3, 2, 3], 2, 3), [], 'destroyer([2, 3, 2, 3], 2, 3)
应该返回[]
。');"
},
{
- "text": "destroyer([\"tree\", \"hamburger\", 53], \"tree\", 53)
应该返回 [\"hamburger\"]
。",
- "testString": "assert.deepEqual(destroyer([\"tree\", \"hamburger\", 53], \"tree\", 53), [\"hamburger\"], 'destroyer([\"tree\", \"hamburger\", 53], \"tree\", 53)
应该返回 [\"hamburger\"]
。');"
+ "text": "destroyer([\"tree\", \"hamburger\", 53], \"tree\", 53)
应该返回[\"hamburger\"]
。",
+ "testString": "assert.deepEqual(destroyer([\"tree\", \"hamburger\", 53], \"tree\", 53), [\"hamburger\"], 'destroyer([\"tree\", \"hamburger\", 53], \"tree\", 53)
应该返回[\"hamburger\"]
。');"
},
{
- "text": "destroyer([\"possum\", \"trollo\", 12, \"safari\", \"hotdog\", 92, 65, \"grandma\", \"bugati\", \"trojan\", \"yacht\"], \"yacht\", \"possum\", \"trollo\", \"safari\", \"hotdog\", \"grandma\", \"bugati\", \"trojan\")
应该返回 [12,92,65]
。",
- "testString": "assert.deepEqual(destroyer([\"possum\", \"trollo\", 12, \"safari\", \"hotdog\", 92, 65, \"grandma\", \"bugati\", \"trojan\", \"yacht\"], \"yacht\", \"possum\", \"trollo\", \"safari\", \"hotdog\", \"grandma\", \"bugati\", \"trojan\"), [12,92,65], 'destroyer([\"possum\", \"trollo\", 12, \"safari\", \"hotdog\", 92, 65, \"grandma\", \"bugati\", \"trojan\", \"yacht\"], \"yacht\", \"possum\", \"trollo\", \"safari\", \"hotdog\", \"grandma\", \"bugati\", \"trojan\")
应该返回 [12,92,65]
。');"
+ "text": "destroyer([\"possum\", \"trollo\", 12, \"safari\", \"hotdog\", 92, 65, \"grandma\", \"bugati\", \"trojan\", \"yacht\"], \"yacht\", \"possum\", \"trollo\", \"safari\", \"hotdog\", \"grandma\", \"bugati\", \"trojan\")
应该返回[12,92,65]
。",
+ "testString": "assert.deepEqual(destroyer([\"possum\", \"trollo\", 12, \"safari\", \"hotdog\", 92, 65, \"grandma\", \"bugati\", \"trojan\", \"yacht\"], \"yacht\", \"possum\", \"trollo\", \"safari\", \"hotdog\", \"grandma\", \"bugati\", \"trojan\"), [12,92,65], 'destroyer([\"possum\", \"trollo\", 12, \"safari\", \"hotdog\", 92, 65, \"grandma\", \"bugati\", \"trojan\", \"yacht\"], \"yacht\", \"possum\", \"trollo\", \"safari\", \"hotdog\", \"grandma\", \"bugati\", \"trojan\")
应该返回[12,92,65]
。');"
}
],
"isRequired": true,
@@ -233,36 +233,36 @@
"title": "Wherefore art thou",
"description": [
"在这道题目中,我们要写一个函数,它接收两个参数:第一个参数是对象数组,第二个参数是一个对象。我们需要从对象数组中找出与第二个参数相等或包含第二个参数的所有对象,并以对象数组的形式返回。其中,相等的意思是原数组中的对象与第二个参数中对象的所有键值对完全相等;包含的意思是只要第二个参数中对象的所有键存在于原数组对象中,且它们对应的值相同即可。",
- "比如,如果第一个参数是 [{ first: \"Romeo\", last: \"Montague\" }, { first: \"Mercutio\", last: null }, { first: \"Tybalt\", last: \"Capulet\" }]
,第二个参数是 { last: \"Capulet\" }
。那么你需要以对象数组的形式返回第一个参数中的第三个元素,因为它包含第二个参数中定义的键 last
,且对应的值 \"Capulet\"
相同",
- "如果你遇到了问题,请点击 帮助。"
+ "比如,如果第一个参数是[{ first: \"Romeo\", last: \"Montague\" }, { first: \"Mercutio\", last: null }, { first: \"Tybalt\", last: \"Capulet\" }]
,第二个参数是{ last: \"Capulet\" }
。那么你需要以对象数组的形式返回第一个参数中的第三个元素,因为它包含第二个参数中定义的键last
,且对应的值\"Capulet\"
相同",
+ "如果你遇到了问题,请点击帮助。"
],
"solutions": [
"function whatIsInAName(collection, source) {\n var arr = [];\n var keys = Object.keys(source);\n collection.forEach(function(e) {\n if(keys.every(function(key) {return e[key] === source[key];})) {\n arr.push(e); \n }\n });\n return arr;\n}"
],
"tests": [
{
- "text": "whatIsInAName([{ first: \"Romeo\", last: \"Montague\" }, { first: \"Mercutio\", last: null }, { first: \"Tybalt\", last: \"Capulet\" }], { last: \"Capulet\" })
应该返回 [{ first: \"Tybalt\", last: \"Capulet\" }]
。",
- "testString": "assert.deepEqual(whatIsInAName([{ first: \"Romeo\", last: \"Montague\" }, { first: \"Mercutio\", last: null }, { first: \"Tybalt\", last: \"Capulet\" }], { last: \"Capulet\" }), [{ first: \"Tybalt\", last: \"Capulet\" }], 'whatIsInAName([{ first: \"Romeo\", last: \"Montague\" }, { first: \"Mercutio\", last: null }, { first: \"Tybalt\", last: \"Capulet\" }], { last: \"Capulet\" })
应该返回 [{ first: \"Tybalt\", last: \"Capulet\" }]
。');"
+ "text": "whatIsInAName([{ first: \"Romeo\", last: \"Montague\" }, { first: \"Mercutio\", last: null }, { first: \"Tybalt\", last: \"Capulet\" }], { last: \"Capulet\" })
应该返回[{ first: \"Tybalt\", last: \"Capulet\" }]
。",
+ "testString": "assert.deepEqual(whatIsInAName([{ first: \"Romeo\", last: \"Montague\" }, { first: \"Mercutio\", last: null }, { first: \"Tybalt\", last: \"Capulet\" }], { last: \"Capulet\" }), [{ first: \"Tybalt\", last: \"Capulet\" }], 'whatIsInAName([{ first: \"Romeo\", last: \"Montague\" }, { first: \"Mercutio\", last: null }, { first: \"Tybalt\", last: \"Capulet\" }], { last: \"Capulet\" })
应该返回[{ first: \"Tybalt\", last: \"Capulet\" }]
。');"
},
{
- "text": "whatIsInAName([{ \"apple\": 1 }, { \"apple\": 1 }, { \"apple\": 1, \"bat\": 2 }], { \"apple\": 1 })
应该返回 [{ \"apple\": 1 }, { \"apple\": 1 }, { \"apple\": 1, \"bat\": 2 }]
。",
- "testString": "assert.deepEqual(whatIsInAName([{ \"apple\": 1 }, { \"apple\": 1 }, { \"apple\": 1, \"bat\": 2 }], { \"apple\": 1 }), [{ \"apple\": 1 }, { \"apple\": 1 }, { \"apple\": 1, \"bat\": 2 }], 'whatIsInAName([{ \"apple\": 1 }, { \"apple\": 1 }, { \"apple\": 1, \"bat\": 2 }], { \"apple\": 1 })
应该返回 [{ \"apple\": 1 }, { \"apple\": 1 }, { \"apple\": 1, \"bat\": 2 }]
。');"
+ "text": "whatIsInAName([{ \"apple\": 1 }, { \"apple\": 1 }, { \"apple\": 1, \"bat\": 2 }], { \"apple\": 1 })
应该返回[{ \"apple\": 1 }, { \"apple\": 1 }, { \"apple\": 1, \"bat\": 2 }]
。",
+ "testString": "assert.deepEqual(whatIsInAName([{ \"apple\": 1 }, { \"apple\": 1 }, { \"apple\": 1, \"bat\": 2 }], { \"apple\": 1 }), [{ \"apple\": 1 }, { \"apple\": 1 }, { \"apple\": 1, \"bat\": 2 }], 'whatIsInAName([{ \"apple\": 1 }, { \"apple\": 1 }, { \"apple\": 1, \"bat\": 2 }], { \"apple\": 1 })
应该返回[{ \"apple\": 1 }, { \"apple\": 1 }, { \"apple\": 1, \"bat\": 2 }]
。');"
},
{
- "text": "whatIsInAName([{ \"apple\": 1, \"bat\": 2 }, { \"bat\": 2 }, { \"apple\": 1, \"bat\": 2, \"cookie\": 2 }], { \"apple\": 1, \"bat\": 2 })
应该返回 [{ \"apple\": 1, \"bat\": 2 }, { \"apple\": 1, \"bat\": 2, \"cookie\": 2 }]
。",
- "testString": "assert.deepEqual(whatIsInAName([{ \"apple\": 1, \"bat\": 2 }, { \"bat\": 2 }, { \"apple\": 1, \"bat\": 2, \"cookie\": 2 }], { \"apple\": 1, \"bat\": 2 }), [{ \"apple\": 1, \"bat\": 2 }, { \"apple\": 1, \"bat\": 2, \"cookie\": 2 }], 'whatIsInAName([{ \"apple\": 1, \"bat\": 2 }, { \"bat\": 2 }, { \"apple\": 1, \"bat\": 2, \"cookie\": 2 }], { \"apple\": 1, \"bat\": 2 })
应该返回 [{ \"apple\": 1, \"bat\": 2 }, { \"apple\": 1, \"bat\": 2, \"cookie\": 2 }]
。');"
+ "text": "whatIsInAName([{ \"apple\": 1, \"bat\": 2 }, { \"bat\": 2 }, { \"apple\": 1, \"bat\": 2, \"cookie\": 2 }], { \"apple\": 1, \"bat\": 2 })
应该返回[{ \"apple\": 1, \"bat\": 2 }, { \"apple\": 1, \"bat\": 2, \"cookie\": 2 }]
。",
+ "testString": "assert.deepEqual(whatIsInAName([{ \"apple\": 1, \"bat\": 2 }, { \"bat\": 2 }, { \"apple\": 1, \"bat\": 2, \"cookie\": 2 }], { \"apple\": 1, \"bat\": 2 }), [{ \"apple\": 1, \"bat\": 2 }, { \"apple\": 1, \"bat\": 2, \"cookie\": 2 }], 'whatIsInAName([{ \"apple\": 1, \"bat\": 2 }, { \"bat\": 2 }, { \"apple\": 1, \"bat\": 2, \"cookie\": 2 }], { \"apple\": 1, \"bat\": 2 })
应该返回[{ \"apple\": 1, \"bat\": 2 }, { \"apple\": 1, \"bat\": 2, \"cookie\": 2 }]
。');"
},
{
- "text": "whatIsInAName([{ \"apple\": 1, \"bat\": 2 }, { \"apple\": 1 }, { \"apple\": 1, \"bat\": 2, \"cookie\": 2 }], { \"apple\": 1, \"cookie\": 2 })
应该返回 [{ \"apple\": 1, \"bat\": 2, \"cookie\": 2 }]
。",
- "testString": "assert.deepEqual(whatIsInAName([{ \"apple\": 1, \"bat\": 2 }, { \"apple\": 1 }, { \"apple\": 1, \"bat\": 2, \"cookie\": 2 }], { \"apple\": 1, \"cookie\": 2 }), [{ \"apple\": 1, \"bat\": 2, \"cookie\": 2 }], 'whatIsInAName([{ \"apple\": 1, \"bat\": 2 }, { \"apple\": 1 }, { \"apple\": 1, \"bat\": 2, \"cookie\": 2 }], { \"apple\": 1, \"cookie\": 2 })
应该返回 [{ \"apple\": 1, \"bat\": 2, \"cookie\": 2 }]
。');"
+ "text": "whatIsInAName([{ \"apple\": 1, \"bat\": 2 }, { \"apple\": 1 }, { \"apple\": 1, \"bat\": 2, \"cookie\": 2 }], { \"apple\": 1, \"cookie\": 2 })
应该返回[{ \"apple\": 1, \"bat\": 2, \"cookie\": 2 }]
。",
+ "testString": "assert.deepEqual(whatIsInAName([{ \"apple\": 1, \"bat\": 2 }, { \"apple\": 1 }, { \"apple\": 1, \"bat\": 2, \"cookie\": 2 }], { \"apple\": 1, \"cookie\": 2 }), [{ \"apple\": 1, \"bat\": 2, \"cookie\": 2 }], 'whatIsInAName([{ \"apple\": 1, \"bat\": 2 }, { \"apple\": 1 }, { \"apple\": 1, \"bat\": 2, \"cookie\": 2 }], { \"apple\": 1, \"cookie\": 2 })
应该返回[{ \"apple\": 1, \"bat\": 2, \"cookie\": 2 }]
。');"
},
{
- "text": "whatIsInAName([{ \"apple\": 1, \"bat\": 2 }, { \"apple\": 1 }, { \"apple\": 1, \"bat\": 2, \"cookie\": 2 }, { \"bat\":2 }], { \"apple\": 1, \"bat\": 2 })
应该返回 [{ \"apple\": 1, \"bat\": 2 }, { \"apple\": 1, \"bat\": 2, \"cookie\":2 }]
。",
- "testString": "assert.deepEqual(whatIsInAName([{ \"apple\": 1, \"bat\": 2 }, { \"apple\": 1 }, { \"apple\": 1, \"bat\": 2, \"cookie\": 2 }, {\"bat\":2}], { \"apple\": 1, \"bat\": 2 }), [{ \"apple\": 1, \"bat\": 2 }, { \"apple\": 1, \"bat\": 2, \"cookie\":2 }], 'whatIsInAName([{ \"apple\": 1, \"bat\": 2 }, { \"apple\": 1 }, { \"apple\": 1, \"bat\": 2, \"cookie\": 2 }, { \"bat\":2 }], { \"apple\": 1, \"bat\": 2 })
应该返回 [{ \"apple\": 1, \"bat\": 2 }, { \"apple\": 1, \"bat\": 2, \"cookie\":2 }]
。');"
+ "text": "whatIsInAName([{ \"apple\": 1, \"bat\": 2 }, { \"apple\": 1 }, { \"apple\": 1, \"bat\": 2, \"cookie\": 2 }, { \"bat\":2 }], { \"apple\": 1, \"bat\": 2 })
应该返回[{ \"apple\": 1, \"bat\": 2 }, { \"apple\": 1, \"bat\": 2, \"cookie\":2 }]
。",
+ "testString": "assert.deepEqual(whatIsInAName([{ \"apple\": 1, \"bat\": 2 }, { \"apple\": 1 }, { \"apple\": 1, \"bat\": 2, \"cookie\": 2 }, {\"bat\":2}], { \"apple\": 1, \"bat\": 2 }), [{ \"apple\": 1, \"bat\": 2 }, { \"apple\": 1, \"bat\": 2, \"cookie\":2 }], 'whatIsInAName([{ \"apple\": 1, \"bat\": 2 }, { \"apple\": 1 }, { \"apple\": 1, \"bat\": 2, \"cookie\": 2 }, { \"bat\":2 }], { \"apple\": 1, \"bat\": 2 })
应该返回[{ \"apple\": 1, \"bat\": 2 }, { \"apple\": 1, \"bat\": 2, \"cookie\":2 }]
。');"
},
{
- "text": "whatIsInAName([{\"a\": 1, \"b\": 2, \"c\": 3}], {\"a\": 1, \"b\": 9999, \"c\": 3})
应该返回 []
。",
- "testString": "assert.deepEqual(whatIsInAName([{ \"a\": 1, \"b\": 2, \"c\": 3 }], { \"a\": 1, \"b\": 9999, \"c\": 3 }), [], 'whatIsInAName([{\"a\": 1, \"b\": 2, \"c\": 3}], {\"a\": 1, \"b\": 9999, \"c\": 3})
应该返回 []
。');"
+ "text": "whatIsInAName([{\"a\": 1, \"b\": 2, \"c\": 3}], {\"a\": 1, \"b\": 9999, \"c\": 3})
应该返回[]
。",
+ "testString": "assert.deepEqual(whatIsInAName([{ \"a\": 1, \"b\": 2, \"c\": 3 }], { \"a\": 1, \"b\": 9999, \"c\": 3 }), [], 'whatIsInAName([{\"a\": 1, \"b\": 2, \"c\": 3}], {\"a\": 1, \"b\": 9999, \"c\": 3})
应该返回[]
。');"
}
],
"MDNlinks": [
@@ -299,32 +299,32 @@
"id": "a103376db3ba46b2d50db289",
"title": "Spinal Tap Case",
"description": [
- "在这道题目中,我们需要写一个函数,把一个字符串转换为“短线连接格式”。短线连接格式的意思是,所有字母都是小写,且用 -
连接。比如,对于 Hello World
,应该转换为 hello-world
;对于 I love_Javascript-VeryMuch
,应该转换为 i-love-javascript-very-much
。",
- "如果你遇到了问题,请点击 帮助。"
+ "在这道题目中,我们需要写一个函数,把一个字符串转换为 “短线连接格式”。短线连接格式的意思是,所有字母都是小写,且用-
连接。比如,对于Hello World
,应该转换为hello-world
;对于I love_Javascript-VeryMuch
,应该转换为i-love-javascript-very-much
。",
+ "如果你遇到了问题,请点击帮助。"
],
"solutions": [
"function spinalCase(str) {\n // \"It's such a fine line between stupid, and clever.\"\n // --David St. Hubbins\n str = str.replace(/([a-z](?=[A-Z]))/g, '$1 ');\n return str.toLowerCase().replace(/\\ |\\_/g, '-');\n}"
],
"tests": [
{
- "text": "spinalCase(\"This Is Spinal Tap\")
应该返回 \"this-is-spinal-tap\"
。",
- "testString": "assert.deepEqual(spinalCase(\"This Is Spinal Tap\"), \"this-is-spinal-tap\", 'spinalCase(\"This Is Spinal Tap\")
应该返回 \"this-is-spinal-tap\"
。');"
+ "text": "spinalCase(\"This Is Spinal Tap\")
应该返回\"this-is-spinal-tap\"
。",
+ "testString": "assert.deepEqual(spinalCase(\"This Is Spinal Tap\"), \"this-is-spinal-tap\", 'spinalCase(\"This Is Spinal Tap\")
应该返回\"this-is-spinal-tap\"
。');"
},
{
- "text": "spinalCase(\"thisIsSpinalTap\")
应该返回 \"this-is-spinal-tap\"
。",
- "testString": "assert.strictEqual(spinalCase('thisIsSpinalTap'), \"this-is-spinal-tap\", 'spinalCase(\"thisIsSpinalTap\")
应该返回 \"this-is-spinal-tap\"
。');"
+ "text": "spinalCase(\"thisIsSpinalTap\")
应该返回\"this-is-spinal-tap\"
。",
+ "testString": "assert.strictEqual(spinalCase('thisIsSpinalTap'), \"this-is-spinal-tap\", 'spinalCase(\"thisIsSpinalTap\")
应该返回\"this-is-spinal-tap\"
。');"
},
{
- "text": "spinalCase(\"The_Andy_Griffith_Show\")
应该返回 \"the-andy-griffith-show\"
。",
- "testString": "assert.strictEqual(spinalCase(\"The_Andy_Griffith_Show\"), \"the-andy-griffith-show\", 'spinalCase(\"The_Andy_Griffith_Show\")
应该返回 \"the-andy-griffith-show\"
。');"
+ "text": "spinalCase(\"The_Andy_Griffith_Show\")
应该返回\"the-andy-griffith-show\"
。",
+ "testString": "assert.strictEqual(spinalCase(\"The_Andy_Griffith_Show\"), \"the-andy-griffith-show\", 'spinalCase(\"The_Andy_Griffith_Show\")
应该返回\"the-andy-griffith-show\"
。');"
},
{
- "text": "spinalCase(\"Teletubbies say Eh-oh\")
应该返回 \"teletubbies-say-eh-oh\"
。",
- "testString": "assert.strictEqual(spinalCase(\"Teletubbies say Eh-oh\"), \"teletubbies-say-eh-oh\", 'spinalCase(\"Teletubbies say Eh-oh\")
应该返回 \"teletubbies-say-eh-oh\"
。');"
+ "text": "spinalCase(\"Teletubbies say Eh-oh\")
应该返回\"teletubbies-say-eh-oh\"
。",
+ "testString": "assert.strictEqual(spinalCase(\"Teletubbies say Eh-oh\"), \"teletubbies-say-eh-oh\", 'spinalCase(\"Teletubbies say Eh-oh\")
应该返回\"teletubbies-say-eh-oh\"
。');"
},
{
- "text": "spinalCase(\"AllThe-small Things\")
应该返回 \"all-the-small-things\"
。",
- "testString": "assert.strictEqual(spinalCase(\"AllThe-small Things\"), \"all-the-small-things\", 'spinalCase(\"AllThe-small Things\")
应该返回 \"all-the-small-things\"
。');"
+ "text": "spinalCase(\"AllThe-small Things\")
应该返回\"all-the-small-things\"
。",
+ "testString": "assert.strictEqual(spinalCase(\"AllThe-small Things\"), \"all-the-small-things\", 'spinalCase(\"AllThe-small Things\")
应该返回\"all-the-small-things\"
。');"
}
],
"MDNlinks": [
@@ -355,43 +355,43 @@
"id": "aa7697ea2477d1316795783b",
"title": "Pig Latin",
"description": [
- "在这道题目中,我们需要写一个函数,把传入的字符串翻译成“儿童黑话”。",
- "儿童黑话的基本转换规则很简单,只需要把一个英文单词的第一个辅音字母或第一组辅音从移到单词的结尾,并在后面加上 ay
即可。在英语中,字母 a、e、i、o、u 为元音,其余的字母均为辅音。辅音从的意思是连续的多个辅音字母。",
- "额外地,如果单词本身是以元音开头的,那只需要在结尾加上 way
。",
+ "在这道题目中,我们需要写一个函数,把传入的字符串翻译成 “儿童黑话”。",
+ "儿童黑话的基本转换规则很简单,只需要把一个英文单词的第一个辅音字母或第一组辅音从移到单词的结尾,并在后面加上ay
即可。在英语中,字母 a、e、i、o、u 为元音,其余的字母均为辅音。辅音从的意思是连续的多个辅音字母。",
+ "额外地,如果单词本身是以元音开头的,那只需要在结尾加上way
。",
"在本题中,传入的单词一定会是英文单词,且所有字母均为小写。",
- "如果你遇到了问题,请点击 帮助。"
+ "如果你遇到了问题,请点击帮助。"
],
"solutions": [
"function translatePigLatin(str) {\n if (isVowel(str.charAt(0))) return str + \"way\";\n var front = [];\n str = str.split('');\n while (str.length && !isVowel(str[0])) {\n front.push(str.shift());\n }\n return [].concat(str, front).join('') + 'ay';\n}\n\nfunction isVowel(c) {\n return ['a', 'e', 'i', 'o', 'u'].indexOf(c.toLowerCase()) !== -1;\n}"
],
"tests": [
{
- "text": "translatePigLatin(\"california\")
应该返回 \"aliforniacay\"。",
- "testString": "assert.deepEqual(translatePigLatin(\"california\"), \"aliforniacay\", 'translatePigLatin(\"california\")
应该返回 \"aliforniacay\"。');"
+ "text": "translatePigLatin(\"california\")
应该返回 \"aliforniacay\"。",
+ "testString": "assert.deepEqual(translatePigLatin(\"california\"), \"aliforniacay\", 'translatePigLatin(\"california\")
应该返回 \"aliforniacay\"。');"
},
{
- "text": "translatePigLatin(\"paragraphs\")
应该返回 \"aragraphspay\"。",
- "testString": "assert.deepEqual(translatePigLatin(\"paragraphs\"), \"aragraphspay\", 'translatePigLatin(\"paragraphs\")
应该返回 \"aragraphspay\"。');"
+ "text": "translatePigLatin(\"paragraphs\")
应该返回 \"aragraphspay\"。",
+ "testString": "assert.deepEqual(translatePigLatin(\"paragraphs\"), \"aragraphspay\", 'translatePigLatin(\"paragraphs\")
应该返回 \"aragraphspay\"。');"
},
{
- "text": "translatePigLatin(\"glove\")
应该返回 \"oveglay\"。",
- "testString": "assert.deepEqual(translatePigLatin(\"glove\"), \"oveglay\", 'translatePigLatin(\"glove\")
应该返回 \"oveglay\"。');"
+ "text": "translatePigLatin(\"glove\")
应该返回 \"oveglay\"。",
+ "testString": "assert.deepEqual(translatePigLatin(\"glove\"), \"oveglay\", 'translatePigLatin(\"glove\")
应该返回 \"oveglay\"。');"
},
{
- "text": "translatePigLatin(\"algorithm\")
应该返回 \"algorithmway\"。",
- "testString": "assert.deepEqual(translatePigLatin(\"algorithm\"), \"algorithmway\", 'translatePigLatin(\"algorithm\")
应该返回 \"algorithmway\"。');"
+ "text": "translatePigLatin(\"algorithm\")
应该返回 \"algorithmway\"。",
+ "testString": "assert.deepEqual(translatePigLatin(\"algorithm\"), \"algorithmway\", 'translatePigLatin(\"algorithm\")
应该返回 \"algorithmway\"。');"
},
{
- "text": "translatePigLatin(\"eight\")
应该返回 \"eightway\"。",
- "testString": "assert.deepEqual(translatePigLatin(\"eight\"), \"eightway\", 'translatePigLatin(\"eight\")
应该返回 \"eightway\"。');"
+ "text": "translatePigLatin(\"eight\")
应该返回 \"eightway\"。",
+ "testString": "assert.deepEqual(translatePigLatin(\"eight\"), \"eightway\", 'translatePigLatin(\"eight\")
应该返回 \"eightway\"。');"
},
{
- "text": "你的代码应当能够处理第一个元音字母在单词结尾的情况。比如 translatePigLatin(\"she\")
应该返回 \"eshay\"。",
- "testString": "assert.deepEqual(translatePigLatin(\"she\"), \"eshay\", '你的代码应当能够处理第一个元音字母在单词结尾的情况。比如 translatePigLatin(\"she\")
应该返回 \"eshay\"。');"
+ "text": "你的代码应当能够处理第一个元音字母在单词结尾的情况。比如translatePigLatin(\"she\")
应该返回 \"eshay\"。",
+ "testString": "assert.deepEqual(translatePigLatin(\"she\"), \"eshay\", '你的代码应当能够处理第一个元音字母在单词结尾的情况。比如translatePigLatin(\"she\")
应该返回 \"eshay\"。');"
},
{
- "text": "你的代码应当能够处理单词中不含元音字母的情况。比如 translatePigLatin(\"rhythm\")
应该返回 \"rhythmay\"。",
- "testString": "assert.deepEqual(translatePigLatin(\"rhythm\"), \"rhythmay\", '你的代码应当能够处理单词中不含元音字母的情况。比如 translatePigLatin(\"rhythm\")
应该返回 \"rhythmay\"。');"
+ "text": "你的代码应当能够处理单词中不含元音字母的情况。比如translatePigLatin(\"rhythm\")
应该返回 \"rhythmay\"。",
+ "testString": "assert.deepEqual(translatePigLatin(\"rhythm\"), \"rhythmay\", '你的代码应当能够处理单词中不含元音字母的情况。比如translatePigLatin(\"rhythm\")
应该返回 \"rhythmay\"。');"
}
],
"MDNlinks": [
@@ -428,32 +428,32 @@
"这个函数接收的第一个参数为待替换的句子。",
"第二个参数为句中需要被替换的单词。",
"第三个参数为替换后的单词。",
- "注意:
你需要保留被替换单词首字母的大小写格式。即如果传入的第二个参数为 \"Book\",第三个参数为 \"dog\",那么替换后的结果应为 \"Dog\"",
- "如果你遇到了问题,请点击 帮助。"
+ "注意:
你需要保留被替换单词首字母的大小写格式。即如果传入的第二个参数为 \"Book\",第三个参数为 \"dog\",那么替换后的结果应为 \"Dog\"",
+ "如果你遇到了问题,请点击帮助。"
],
"solutions": [
"function myReplace(str, before, after) {\n if (before.charAt(0) === before.charAt(0).toUpperCase()) {\n after = after.charAt(0).toUpperCase() + after.substring(1);\n } else {\n after = after.charAt(0).toLowerCase() + after.substring(1);\n }\n return str.replace(before, after);\n}"
],
"tests": [
{
- "text": "myReplace(\"Let us go to the store\", \"store\", \"mall\")
应该返回 \"Let us go to the mall\"。",
- "testString": "assert.deepEqual(myReplace(\"Let us go to the store\", \"store\", \"mall\"), \"Let us go to the mall\", 'myReplace(\"Let us go to the store\", \"store\", \"mall\")
应该返回 \"Let us go to the mall\"。');"
+ "text": "myReplace(\"Let us go to the store\", \"store\", \"mall\")
应该返回 \"Let us go to the mall\"。",
+ "testString": "assert.deepEqual(myReplace(\"Let us go to the store\", \"store\", \"mall\"), \"Let us go to the mall\", 'myReplace(\"Let us go to the store\", \"store\", \"mall\")
应该返回 \"Let us go to the mall\"。');"
},
{
- "text": "myReplace(\"He is Sleeping on the couch\", \"Sleeping\", \"sitting\")
应该返回 \"He is Sitting on the couch\"。",
- "testString": "assert.deepEqual(myReplace(\"He is Sleeping on the couch\", \"Sleeping\", \"sitting\"), \"He is Sitting on the couch\", 'myReplace(\"He is Sleeping on the couch\", \"Sleeping\", \"sitting\")
应该返回 \"He is Sitting on the couch\"。');"
+ "text": "myReplace(\"He is Sleeping on the couch\", \"Sleeping\", \"sitting\")
应该返回 \"He is Sitting on the couch\"。",
+ "testString": "assert.deepEqual(myReplace(\"He is Sleeping on the couch\", \"Sleeping\", \"sitting\"), \"He is Sitting on the couch\", 'myReplace(\"He is Sleeping on the couch\", \"Sleeping\", \"sitting\")
应该返回 \"He is Sitting on the couch\"。');"
},
{
- "text": "myReplace(\"This has a spellngi error\", \"spellngi\", \"spelling\")
应该返回 \"This has a spelling error\"。",
- "testString": "assert.deepEqual(myReplace(\"This has a spellngi error\", \"spellngi\", \"spelling\"), \"This has a spelling error\", 'myReplace(\"This has a spellngi error\", \"spellngi\", \"spelling\")
应该返回 \"This has a spelling error\"。');"
+ "text": "myReplace(\"This has a spellngi error\", \"spellngi\", \"spelling\")
应该返回 \"This has a spelling error\"。",
+ "testString": "assert.deepEqual(myReplace(\"This has a spellngi error\", \"spellngi\", \"spelling\"), \"This has a spelling error\", 'myReplace(\"This has a spellngi error\", \"spellngi\", \"spelling\")
应该返回 \"This has a spelling error\"。');"
},
{
- "text": "myReplace(\"His name is Tom\", \"Tom\", \"john\")
应该返回 \"His name is John\"。",
- "testString": "assert.deepEqual(myReplace(\"His name is Tom\", \"Tom\", \"john\"), \"His name is John\", 'myReplace(\"His name is Tom\", \"Tom\", \"john\")
应该返回 \"His name is John\"。');"
+ "text": "myReplace(\"His name is Tom\", \"Tom\", \"john\")
应该返回 \"His name is John\"。",
+ "testString": "assert.deepEqual(myReplace(\"His name is Tom\", \"Tom\", \"john\"), \"His name is John\", 'myReplace(\"His name is Tom\", \"Tom\", \"john\")
应该返回 \"His name is John\"。');"
},
{
- "text": "myReplace(\"Let us get back to more Coding\", \"Coding\", \"algorithms\")
应该返回 \"Let us get back to more Algorithms\"。",
- "testString": "assert.deepEqual(myReplace(\"Let us get back to more Coding\", \"Coding\", \"algorithms\"), \"Let us get back to more Algorithms\", 'myReplace(\"Let us get back to more Coding\", \"Coding\", \"algorithms\")
应该返回 \"Let us get back to more Algorithms\"。');"
+ "text": "myReplace(\"Let us get back to more Coding\", \"Coding\", \"algorithms\")
应该返回 \"Let us get back to more Algorithms\"。",
+ "testString": "assert.deepEqual(myReplace(\"Let us get back to more Coding\", \"Coding\", \"algorithms\"), \"Let us get back to more Algorithms\", 'myReplace(\"Let us get back to more Coding\", \"Coding\", \"algorithms\")
应该返回 \"Let us get back to more Algorithms\"。');"
}
],
"MDNlinks": [
@@ -488,23 +488,23 @@
"碱基对 由一对碱基组成。碱基有四种,分别为 A(腺嘌呤)、T(胸腺嘧啶)、G(鸟嘌呤)和 C(胞嘧啶)。配对原则是:A 与 T 配对,C 与 G 配对。我们需要根据这个原则对传入的所有碱基进行配对。",
"对于每个传入的碱基,我们应采用数组的形式展示配对结果。其中,传入的碱基需要作为数组的第一个元素出现。最终返回的数组中应当包含参数中每一个碱基的配对结果。",
"比如,传入的参数是 GCG,那么函数的返回值应为 [[\"G\", \"C\"], [\"C\",\"G\"],[\"G\", \"C\"]]",
- "如果你遇到了问题,请点击 帮助。"
+ "如果你遇到了问题,请点击帮助。"
],
"solutions": [
"var lookup = Object.create(null);\nlookup.A = 'T';\nlookup.T = 'A';\nlookup.C = 'G';\nlookup.G = 'C';\n\nfunction pairElement(str) {\n return str.split('').map(function(p) {return [p, lookup[p]];});\n}"
],
"tests": [
{
- "text": "pairElement(\"ATCGA\")
应该返回 [[\"A\",\"T\"],[\"T\",\"A\"],[\"C\",\"G\"],[\"G\",\"C\"],[\"A\",\"T\"]]
。",
- "testString": "assert.deepEqual(pairElement(\"ATCGA\"),[[\"A\",\"T\"],[\"T\",\"A\"],[\"C\",\"G\"],[\"G\",\"C\"],[\"A\",\"T\"]], 'pairElement(\"ATCGA\")
应该返回 [[\"A\",\"T\"],[\"T\",\"A\"],[\"C\",\"G\"],[\"G\",\"C\"],[\"A\",\"T\"]]
。');"
+ "text": "pairElement(\"ATCGA\")
应该返回[[\"A\",\"T\"],[\"T\",\"A\"],[\"C\",\"G\"],[\"G\",\"C\"],[\"A\",\"T\"]]
。",
+ "testString": "assert.deepEqual(pairElement(\"ATCGA\"),[[\"A\",\"T\"],[\"T\",\"A\"],[\"C\",\"G\"],[\"G\",\"C\"],[\"A\",\"T\"]], 'pairElement(\"ATCGA\")
应该返回[[\"A\",\"T\"],[\"T\",\"A\"],[\"C\",\"G\"],[\"G\",\"C\"],[\"A\",\"T\"]]
。');"
},
{
- "text": "pairElement(\"TTGAG\")
应该返回 [[\"T\",\"A\"],[\"T\",\"A\"],[\"G\",\"C\"],[\"A\",\"T\"],[\"G\",\"C\"]]
。",
- "testString": "assert.deepEqual(pairElement(\"TTGAG\"),[[\"T\",\"A\"],[\"T\",\"A\"],[\"G\",\"C\"],[\"A\",\"T\"],[\"G\",\"C\"]], 'pairElement(\"TTGAG\")
应该返回 [[\"T\",\"A\"],[\"T\",\"A\"],[\"G\",\"C\"],[\"A\",\"T\"],[\"G\",\"C\"]]
。');"
+ "text": "pairElement(\"TTGAG\")
应该返回[[\"T\",\"A\"],[\"T\",\"A\"],[\"G\",\"C\"],[\"A\",\"T\"],[\"G\",\"C\"]]
。",
+ "testString": "assert.deepEqual(pairElement(\"TTGAG\"),[[\"T\",\"A\"],[\"T\",\"A\"],[\"G\",\"C\"],[\"A\",\"T\"],[\"G\",\"C\"]], 'pairElement(\"TTGAG\")
应该返回[[\"T\",\"A\"],[\"T\",\"A\"],[\"G\",\"C\"],[\"A\",\"T\"],[\"G\",\"C\"]]
。');"
},
{
- "text": "pairElement(\"CTCTA\")
应该返回 [[\"C\",\"G\"],[\"T\",\"A\"],[\"C\",\"G\"],[\"T\",\"A\"],[\"A\",\"T\"]]
。",
- "testString": "assert.deepEqual(pairElement(\"CTCTA\"),[[\"C\",\"G\"],[\"T\",\"A\"],[\"C\",\"G\"],[\"T\",\"A\"],[\"A\",\"T\"]], 'pairElement(\"CTCTA\")
应该返回 [[\"C\",\"G\"],[\"T\",\"A\"],[\"C\",\"G\"],[\"T\",\"A\"],[\"A\",\"T\"]]
。');"
+ "text": "pairElement(\"CTCTA\")
应该返回[[\"C\",\"G\"],[\"T\",\"A\"],[\"C\",\"G\"],[\"T\",\"A\"],[\"A\",\"T\"]]
。",
+ "testString": "assert.deepEqual(pairElement(\"CTCTA\"),[[\"C\",\"G\"],[\"T\",\"A\"],[\"C\",\"G\"],[\"T\",\"A\"],[\"A\",\"T\"]], 'pairElement(\"CTCTA\")
应该返回[[\"C\",\"G\"],[\"T\",\"A\"],[\"C\",\"G\"],[\"T\",\"A\"],[\"A\",\"T\"]]
。');"
}
],
"MDNlinks": [
@@ -535,32 +535,32 @@
"title": "Missing letters",
"description": [
"在这道题目中,我们需要写一个函数,找到传入的字符串里缺失的字母并返回它。",
- "判断缺失的依据是字母顺序,比如 abcdfg 中缺失了 e。而 abcdef 中就没有字母缺失,此时我们需要返回 undefined
。",
- "如果你遇到了问题,请点击 帮助。"
+ "判断缺失的依据是字母顺序,比如 abcdfg 中缺失了 e。而 abcdef 中就没有字母缺失,此时我们需要返回undefined
。",
+ "如果你遇到了问题,请点击帮助。"
],
"solutions": [
"function fearNotLetter (str) {\n for (var i = str.charCodeAt(0); i <= str.charCodeAt(str.length - 1); i++) {\n var letter = String.fromCharCode(i);\n if (str.indexOf(letter) === -1) {\n return letter;\n }\n }\n \n return undefined;\n}"
],
"tests": [
{
- "text": "fearNotLetter(\"abce\")
应该返回 \"d\"。",
- "testString": "assert.deepEqual(fearNotLetter('abce'), 'd', 'fearNotLetter(\"abce\")
应该返回 \"d\"。');"
+ "text": "fearNotLetter(\"abce\")
应该返回 \"d\"。",
+ "testString": "assert.deepEqual(fearNotLetter('abce'), 'd', 'fearNotLetter(\"abce\")
应该返回 \"d\"。');"
},
{
- "text": "fearNotLetter(\"abcdefghjklmno\")
应该返回 \"i\"。",
- "testString": "assert.deepEqual(fearNotLetter('abcdefghjklmno'), 'i', 'fearNotLetter(\"abcdefghjklmno\")
应该返回 \"i\"。');"
+ "text": "fearNotLetter(\"abcdefghjklmno\")
应该返回 \"i\"。",
+ "testString": "assert.deepEqual(fearNotLetter('abcdefghjklmno'), 'i', 'fearNotLetter(\"abcdefghjklmno\")
应该返回 \"i\"。');"
},
{
- "text": "fearNotLetter(\"stvwx\")
应该返回 \"u\"。",
- "testString": "assert.deepEqual(fearNotLetter('stvwx'), 'u', 'fearNotLetter(\"stvwx\")
应该返回 \"u\"。');"
+ "text": "fearNotLetter(\"stvwx\")
应该返回 \"u\"。",
+ "testString": "assert.deepEqual(fearNotLetter('stvwx'), 'u', 'fearNotLetter(\"stvwx\")
应该返回 \"u\"。');"
},
{
- "text": "fearNotLetter(\"bcdf\")
应该返回 \"e\"。",
- "testString": "assert.deepEqual(fearNotLetter('bcdf'), 'e', 'fearNotLetter(\"bcdf\")
应该返回 \"e\"。');"
+ "text": "fearNotLetter(\"bcdf\")
应该返回 \"e\"。",
+ "testString": "assert.deepEqual(fearNotLetter('bcdf'), 'e', 'fearNotLetter(\"bcdf\")
应该返回 \"e\"。');"
},
{
- "text": "fearNotLetter(\"abcdefghijklmnopqrstuvwxyz\")
应该返回 undefined
。",
- "testString": "assert.isUndefined(fearNotLetter('abcdefghijklmnopqrstuvwxyz'), 'fearNotLetter(\"abcdefghijklmnopqrstuvwxyz\")
应该返回 undefined
。');"
+ "text": "fearNotLetter(\"abcdefghijklmnopqrstuvwxyz\")
应该返回undefined
。",
+ "testString": "assert.isUndefined(fearNotLetter('abcdefghijklmnopqrstuvwxyz'), 'fearNotLetter(\"abcdefghijklmnopqrstuvwxyz\")
应该返回undefined
。');"
}
],
"MDNlinks": [
@@ -593,27 +593,27 @@
"在这道题目中,我们需要写一个函数,它接收两个或多个数组为参数。我们需要对这些数组中所有元素进行去除重复元素的处理,并以数组的形式返回去重结果。",
"需要注意的是,结果数组中的元素顺序必须与其传入的顺序保持一致。",
"如有疑问,请先浏览下方的测试用例。",
- "如果你遇到了问题,请点击 帮助。"
+ "如果你遇到了问题,请点击帮助。"
],
"solutions": [
"function uniteUnique(arr) {\n return [].slice.call(arguments).reduce(function(a, b) {\n return [].concat(a, b.filter(function(e) {return a.indexOf(e) === -1;}));\n }, []);\n}"
],
"tests": [
{
- "text": "uniteUnique([1, 3, 2], [5, 2, 1, 4], [2, 1])
应该返回 [1, 3, 2, 5, 4]
。",
- "testString": "assert.deepEqual(uniteUnique([1, 3, 2], [5, 2, 1, 4], [2, 1]), [1, 3, 2, 5, 4], 'uniteUnique([1, 3, 2], [5, 2, 1, 4], [2, 1])
应该返回 [1, 3, 2, 5, 4]
。');"
+ "text": "uniteUnique([1, 3, 2], [5, 2, 1, 4], [2, 1])
应该返回[1, 3, 2, 5, 4]
。",
+ "testString": "assert.deepEqual(uniteUnique([1, 3, 2], [5, 2, 1, 4], [2, 1]), [1, 3, 2, 5, 4], 'uniteUnique([1, 3, 2], [5, 2, 1, 4], [2, 1])
应该返回[1, 3, 2, 5, 4]
。');"
},
{
- "text": "uniteUnique([1, 3, 2], [1, [5]], [2, [4]])
应该返回 [1, 3, 2, [5], [4]]
。",
- "testString": "assert.deepEqual(uniteUnique([1, 3, 2], [1, [5]], [2, [4]]), [1, 3, 2, [5], [4]], 'uniteUnique([1, 3, 2], [1, [5]], [2, [4]])
应该返回 [1, 3, 2, [5], [4]]
。');"
+ "text": "uniteUnique([1, 3, 2], [1, [5]], [2, [4]])
应该返回[1, 3, 2, [5], [4]]
。",
+ "testString": "assert.deepEqual(uniteUnique([1, 3, 2], [1, [5]], [2, [4]]), [1, 3, 2, [5], [4]], 'uniteUnique([1, 3, 2], [1, [5]], [2, [4]])
应该返回[1, 3, 2, [5], [4]]
。');"
},
{
- "text": "uniteUnique([1, 2, 3], [5, 2, 1])
应该返回 [1, 2, 3, 5]
。",
- "testString": "assert.deepEqual(uniteUnique([1, 2, 3], [5, 2, 1]), [1, 2, 3, 5], 'uniteUnique([1, 2, 3], [5, 2, 1])
应该返回 [1, 2, 3, 5]
。');"
+ "text": "uniteUnique([1, 2, 3], [5, 2, 1])
应该返回[1, 2, 3, 5]
。",
+ "testString": "assert.deepEqual(uniteUnique([1, 2, 3], [5, 2, 1]), [1, 2, 3, 5], 'uniteUnique([1, 2, 3], [5, 2, 1])
应该返回[1, 2, 3, 5]
。');"
},
{
- "text": "uniteUnique([1, 2, 3], [5, 2, 1, 4], [2, 1], [6, 7, 8])
应该返回 [1, 2, 3, 5, 4, 6, 7, 8]
。",
- "testString": "assert.deepEqual(uniteUnique([1, 2, 3], [5, 2, 1, 4], [2, 1], [6, 7, 8]), [1, 2, 3, 5, 4, 6, 7, 8], 'uniteUnique([1, 2, 3], [5, 2, 1, 4], [2, 1], [6, 7, 8])
应该返回 [1, 2, 3, 5, 4, 6, 7, 8]
。');"
+ "text": "uniteUnique([1, 2, 3], [5, 2, 1, 4], [2, 1], [6, 7, 8])
应该返回[1, 2, 3, 5, 4, 6, 7, 8]
。",
+ "testString": "assert.deepEqual(uniteUnique([1, 2, 3], [5, 2, 1, 4], [2, 1], [6, 7, 8]), [1, 2, 3, 5, 4, 6, 7, 8], 'uniteUnique([1, 2, 3], [5, 2, 1, 4], [2, 1], [6, 7, 8])
应该返回[1, 2, 3, 5, 4, 6, 7, 8]
。');"
}
],
"MDNlinks": [
@@ -643,40 +643,40 @@
"id": "a6b0bb188d873cb2c8729495",
"title": "Convert HTML Entities",
"description": [
- "在这道题目中,我们需要写一个转换 HTML entity 的函数。需要转换的 HTML entity 有 &
、<
、>
、\"
(双引号)和 '
(单引号)。转换的规则你可以在 W3C 官网找到。",
- "如果你遇到了问题,请点击 帮助。"
+ "在这道题目中,我们需要写一个转换 HTML entity 的函数。需要转换的 HTML entity 有&
、<
、>
、\"
(双引号)和'
(单引号)。转换的规则你可以在 W3C 官网找到。",
+ "如果你遇到了问题,请点击帮助。"
],
"solutions": [
"var MAP = { '&': '&',\n '<': '<',\n '>': '>',\n '\"': '"',\n \"'\": '''};\n\nfunction convertHTML(str) {\n return str.replace(/[&<>\"']/g, function(c) {\n return MAP[c];\n });\n}"
],
"tests": [
{
- "text": "convertHTML(\"Dolce & Gabbana\")
应该返回 Dolce & Gabbana
。",
- "testString": "assert.match(convertHTML(\"Dolce & Gabbana\"), /Dolce & Gabbana/, 'convertHTML(\"Dolce & Gabbana\")
应该返回 Dolce & Gabbana
。');"
+ "text": "convertHTML(\"Dolce & Gabbana\")
应该返回Dolce & Gabbana
。",
+ "testString": "assert.match(convertHTML(\"Dolce & Gabbana\"), /Dolce & Gabbana/, 'convertHTML(\"Dolce & Gabbana\")
应该返回Dolce & Gabbana
。');"
},
{
- "text": "convertHTML(\"Hamburgers < Pizza < Tacos\")
应该返回 Hamburgers < Pizza < Tacos
。",
- "testString": "assert.match(convertHTML(\"Hamburgers < Pizza < Tacos\"), /Hamburgers < Pizza < Tacos/, 'convertHTML(\"Hamburgers < Pizza < Tacos\")
应该返回 Hamburgers < Pizza < Tacos
。');"
+ "text": "convertHTML(\"Hamburgers < Pizza < Tacos\")
应该返回Hamburgers < Pizza < Tacos
。",
+ "testString": "assert.match(convertHTML(\"Hamburgers < Pizza < Tacos\"), /Hamburgers < Pizza < Tacos/, 'convertHTML(\"Hamburgers < Pizza < Tacos\")
应该返回Hamburgers < Pizza < Tacos
。');"
},
{
- "text": "convertHTML(\"Sixty > twelve\")
应该返回 Sixty > twelve
。",
- "testString": "assert.match(convertHTML(\"Sixty > twelve\"), /Sixty > twelve/, 'convertHTML(\"Sixty > twelve\")
应该返回 Sixty > twelve
。');"
+ "text": "convertHTML(\"Sixty > twelve\")
应该返回Sixty > twelve
。",
+ "testString": "assert.match(convertHTML(\"Sixty > twelve\"), /Sixty > twelve/, 'convertHTML(\"Sixty > twelve\")
应该返回Sixty > twelve
。');"
},
{
- "text": "convertHTML('Stuff in \"quotation marks\"')
应该返回 Stuff in "quotation marks"
。",
- "testString": "assert.match(convertHTML('Stuff in \"quotation marks\"'), /Stuff in "quotation marks"/, 'convertHTML('Stuff in \"quotation marks\"')
应该返回 Stuff in "quotation marks"
。');"
+ "text": "convertHTML('Stuff in \"quotation marks\"')
应该返回Stuff in "quotation marks"
。",
+ "testString": "assert.match(convertHTML('Stuff in \"quotation marks\"'), /Stuff in "quotation marks"/, 'convertHTML('Stuff in \"quotation marks\"')
应该返回Stuff in "quotation marks"
。');"
},
{
- "text": "convertHTML(\"Schindler's List\")
应该返回 Schindler's List
。",
- "testString": "assert.match(convertHTML(\"Schindler's List\"), /Schindler's List/, 'convertHTML(\"Schindler's List\")
应该返回 Schindler's List
。');"
+ "text": "convertHTML(\"Schindler's List\")
应该返回Schindler's List
。",
+ "testString": "assert.match(convertHTML(\"Schindler's List\"), /Schindler's List/, 'convertHTML(\"Schindler's List\")
应该返回Schindler's List
。');"
},
{
- "text": "convertHTML(\"<>\")
应该返回 <>
。",
- "testString": "assert.match(convertHTML('<>'), /<>/, 'convertHTML(\"<>\")
应该返回 <>
。');"
+ "text": "convertHTML(\"<>\")
应该返回<>
。",
+ "testString": "assert.match(convertHTML('<>'), /<>/, 'convertHTML(\"<>\")
应该返回<>
。');"
},
{
- "text": "convertHTML(\"abc\")
应该返回 abc
。",
- "testString": "assert.strictEqual(convertHTML('abc'), 'abc', 'convertHTML(\"abc\")
应该返回 abc
。');"
+ "text": "convertHTML(\"abc\")
应该返回abc
。",
+ "testString": "assert.strictEqual(convertHTML('abc'), 'abc', 'convertHTML(\"abc\")
应该返回abc
。');"
}
],
"MDNlinks": [
@@ -708,9 +708,9 @@
"id": "a5229172f011153519423690",
"title": "Sum All Odd Fibonacci Numbers",
"description": [
- "Given a positive integer num
, return the sum of all odd Fibonacci numbers that are less than or equal to num
.",
+ "Given a positive integernum
, return the sum of all odd Fibonacci numbers that are less than or equal tonum
.",
"The first two numbers in the Fibonacci sequence are 1 and 1. Every additional number in the sequence is the sum of the two previous numbers. The first six numbers of the Fibonacci sequence are 1, 1, 2, 3, 5 and 8.",
- "For example, sumFibs(10)
should return 10
because all odd Fibonacci numbers less than or equal to 10
are 1, 1, 3, and 5.",
+ "For example,sumFibs(10)
should return10
because all odd Fibonacci numbers less than or equal to10
are 1, 1, 3, and 5.",
"Remember to use Read-Search-Ask if you get stuck. Try to pair program. Write your own code."
],
"solutions": [
@@ -718,28 +718,28 @@
],
"tests": [
{
- "text": "sumFibs(1)
should return a number.",
- "testString": "assert(typeof sumFibs(1) === \"number\", 'sumFibs(1)
should return a number.');"
+ "text": "sumFibs(1)
should return a number.",
+ "testString": "assert(typeof sumFibs(1) === \"number\", 'sumFibs(1)
should return a number.');"
},
{
- "text": "sumFibs(1000)
should return 1785.",
- "testString": "assert(sumFibs(1000) === 1785, 'sumFibs(1000)
should return 1785.');"
+ "text": "sumFibs(1000)
should return 1785.",
+ "testString": "assert(sumFibs(1000) === 1785, 'sumFibs(1000)
should return 1785.');"
},
{
- "text": "sumFibs(4000000)
should return 4613732.",
- "testString": "assert(sumFibs(4000000) === 4613732, 'sumFibs(4000000)
should return 4613732.');"
+ "text": "sumFibs(4000000)
should return 4613732.",
+ "testString": "assert(sumFibs(4000000) === 4613732, 'sumFibs(4000000)
should return 4613732.');"
},
{
- "text": "sumFibs(4)
should return 5.",
- "testString": "assert(sumFibs(4) === 5, 'sumFibs(4)
should return 5.');"
+ "text": "sumFibs(4)
should return 5.",
+ "testString": "assert(sumFibs(4) === 5, 'sumFibs(4)
should return 5.');"
},
{
- "text": "sumFibs(75024)
should return 60696.",
- "testString": "assert(sumFibs(75024) === 60696, 'sumFibs(75024)
should return 60696.');"
+ "text": "sumFibs(75024)
should return 60696.",
+ "testString": "assert(sumFibs(75024) === 60696, 'sumFibs(75024)
should return 60696.');"
},
{
- "text": "sumFibs(75025)
should return 135721.",
- "testString": "assert(sumFibs(75025) === 135721, 'sumFibs(75025)
should return 135721.');"
+ "text": "sumFibs(75025)
should return 135721.",
+ "testString": "assert(sumFibs(75025) === 135721, 'sumFibs(75025)
should return 135721.');"
}
],
"MDNlinks": [
@@ -778,16 +778,16 @@
],
"tests": [
{
- "text": "sumPrimes(10)
should return a number.",
- "testString": "assert.deepEqual(typeof sumPrimes(10), 'number', 'sumPrimes(10)
should return a number.');"
+ "text": "sumPrimes(10)
should return a number.",
+ "testString": "assert.deepEqual(typeof sumPrimes(10), 'number', 'sumPrimes(10)
should return a number.');"
},
{
- "text": "sumPrimes(10)
should return 17.",
- "testString": "assert.deepEqual(sumPrimes(10), 17, 'sumPrimes(10)
should return 17.');"
+ "text": "sumPrimes(10)
should return 17.",
+ "testString": "assert.deepEqual(sumPrimes(10), 17, 'sumPrimes(10)
should return 17.');"
},
{
- "text": "sumPrimes(977)
should return 73156.",
- "testString": "assert.deepEqual(sumPrimes(977), 73156, 'sumPrimes(977)
should return 73156.');"
+ "text": "sumPrimes(977)
should return 73156.",
+ "testString": "assert.deepEqual(sumPrimes(977), 73156, 'sumPrimes(977)
should return 73156.');"
}
],
"MDNlinks": [
@@ -827,28 +827,28 @@
],
"tests": [
{
- "text": "smallestCommons([1, 5])
should return a number.",
- "testString": "assert.deepEqual(typeof smallestCommons([1, 5]), 'number', 'smallestCommons([1, 5])
should return a number.');"
+ "text": "smallestCommons([1, 5])
should return a number.",
+ "testString": "assert.deepEqual(typeof smallestCommons([1, 5]), 'number', 'smallestCommons([1, 5])
should return a number.');"
},
{
- "text": "smallestCommons([1, 5])
should return 60.",
- "testString": "assert.deepEqual(smallestCommons([1, 5]), 60, 'smallestCommons([1, 5])
should return 60.');"
+ "text": "smallestCommons([1, 5])
should return 60.",
+ "testString": "assert.deepEqual(smallestCommons([1, 5]), 60, 'smallestCommons([1, 5])
should return 60.');"
},
{
- "text": "smallestCommons([5, 1])
should return 60.",
- "testString": "assert.deepEqual(smallestCommons([5, 1]), 60, 'smallestCommons([5, 1])
should return 60.');"
+ "text": "smallestCommons([5, 1])
should return 60.",
+ "testString": "assert.deepEqual(smallestCommons([5, 1]), 60, 'smallestCommons([5, 1])
should return 60.');"
},
{
- "text": "smallestCommons([2, 10])
should return 2520.",
- "testString": "assert.deepEqual(smallestCommons([2, 10]), 2520, 'smallestCommons([2, 10])
should return 2520.');"
+ "text": "smallestCommons([2, 10])
should return 2520.",
+ "testString": "assert.deepEqual(smallestCommons([2, 10]), 2520, 'smallestCommons([2, 10])
should return 2520.');"
},
{
- "text": "smallestCommons([1, 13])
should return 360360.",
- "testString": "assert.deepEqual(smallestCommons([1, 13]), 360360, 'smallestCommons([1, 13])
should return 360360.');"
+ "text": "smallestCommons([1, 13])
should return 360360.",
+ "testString": "assert.deepEqual(smallestCommons([1, 13]), 360360, 'smallestCommons([1, 13])
should return 360360.');"
},
{
- "text": "smallestCommons([23, 18])
should return 6056820.",
- "testString": "assert.deepEqual(smallestCommons([23, 18]), 6056820, 'smallestCommons([23, 18])
should return 6056820.');"
+ "text": "smallestCommons([23, 18])
should return 6056820.",
+ "testString": "assert.deepEqual(smallestCommons([23, 18]), 6056820, 'smallestCommons([23, 18])
should return 6056820.');"
}
],
"MDNlinks": [
@@ -878,8 +878,8 @@
"id": "a5deed1811a43193f9f1c841",
"title": "Drop it",
"description": [
- "Given the array arr
, iterate through and remove each element starting from the first element (the 0 index) until the function func
returns true
when the iterated element is passed through it.",
- "Then return the rest of the array once the condition is satisfied, otherwise, arr
should be returned as an empty array.",
+ "Given the arrayarr
, iterate through and remove each element starting from the first element (the 0 index) until the functionfunc
returnstrue
when the iterated element is passed through it.",
+ "Then return the rest of the array once the condition is satisfied, otherwise,arr
should be returned as an empty array.",
"Remember to use Read-Search-Ask if you get stuck. Try to pair program. Write your own code."
],
"solutions": [
@@ -887,28 +887,28 @@
],
"tests": [
{
- "text": "dropElements([1, 2, 3, 4], function(n) {return n >= 3;})
should return [3, 4]
.",
- "testString": "assert.deepEqual(dropElements([1, 2, 3, 4], function(n) {return n >= 3;}), [3, 4], 'dropElements([1, 2, 3, 4], function(n) {return n >= 3;})
should return [3, 4]
.');"
+ "text": "dropElements([1, 2, 3, 4], function(n) {return n >= 3;})
should return[3, 4]
.",
+ "testString": "assert.deepEqual(dropElements([1, 2, 3, 4], function(n) {return n >= 3;}), [3, 4], 'dropElements([1, 2, 3, 4], function(n) {return n >= 3;})
should return[3, 4]
.');"
},
{
- "text": "dropElements([0, 1, 0, 1], function(n) {return n === 1;})
should return [1, 0, 1]
.",
- "testString": "assert.deepEqual(dropElements([0, 1, 0, 1], function(n) {return n === 1;}), [1, 0, 1], 'dropElements([0, 1, 0, 1], function(n) {return n === 1;})
should return [1, 0, 1]
.');"
+ "text": "dropElements([0, 1, 0, 1], function(n) {return n === 1;})
should return[1, 0, 1]
.",
+ "testString": "assert.deepEqual(dropElements([0, 1, 0, 1], function(n) {return n === 1;}), [1, 0, 1], 'dropElements([0, 1, 0, 1], function(n) {return n === 1;})
should return[1, 0, 1]
.');"
},
{
- "text": "dropElements([1, 2, 3], function(n) {return n > 0;})
should return [1, 2, 3]
.",
- "testString": "assert.deepEqual(dropElements([1, 2, 3], function(n) {return n > 0;}), [1, 2, 3], 'dropElements([1, 2, 3], function(n) {return n > 0;})
should return [1, 2, 3]
.');"
+ "text": "dropElements([1, 2, 3], function(n) {return n > 0;})
should return[1, 2, 3]
.",
+ "testString": "assert.deepEqual(dropElements([1, 2, 3], function(n) {return n > 0;}), [1, 2, 3], 'dropElements([1, 2, 3], function(n) {return n > 0;})
should return[1, 2, 3]
.');"
},
{
- "text": "dropElements([1, 2, 3, 4], function(n) {return n > 5;})
should return []
.",
- "testString": "assert.deepEqual(dropElements([1, 2, 3, 4], function(n) {return n > 5;}), [], 'dropElements([1, 2, 3, 4], function(n) {return n > 5;})
should return []
.');"
+ "text": "dropElements([1, 2, 3, 4], function(n) {return n > 5;})
should return[]
.",
+ "testString": "assert.deepEqual(dropElements([1, 2, 3, 4], function(n) {return n > 5;}), [], 'dropElements([1, 2, 3, 4], function(n) {return n > 5;})
should return[]
.');"
},
{
- "text": "dropElements([1, 2, 3, 7, 4], function(n) {return n > 3;})
should return [7, 4]
.",
- "testString": "assert.deepEqual(dropElements([1, 2, 3, 7, 4], function(n) {return n > 3;}), [7, 4], 'dropElements([1, 2, 3, 7, 4], function(n) {return n > 3;})
should return [7, 4]
.');"
+ "text": "dropElements([1, 2, 3, 7, 4], function(n) {return n > 3;})
should return[7, 4]
.",
+ "testString": "assert.deepEqual(dropElements([1, 2, 3, 7, 4], function(n) {return n > 3;}), [7, 4], 'dropElements([1, 2, 3, 7, 4], function(n) {return n > 3;})
should return[7, 4]
.');"
},
{
- "text": "dropElements([1, 2, 3, 9, 2], function(n) {return n > 2;})
should return [3, 9, 2]
.",
- "testString": "assert.deepEqual(dropElements([1, 2, 3, 9, 2], function(n) {return n > 2;}), [3, 9, 2], 'dropElements([1, 2, 3, 9, 2], function(n) {return n > 2;})
should return [3, 9, 2]
.');"
+ "text": "dropElements([1, 2, 3, 9, 2], function(n) {return n > 2;})
should return[3, 9, 2]
.",
+ "testString": "assert.deepEqual(dropElements([1, 2, 3, 9, 2], function(n) {return n > 2;}), [3, 9, 2], 'dropElements([1, 2, 3, 9, 2], function(n) {return n > 2;})
should return[3, 9, 2]
.');"
}
],
"MDNlinks": [
@@ -948,20 +948,20 @@
],
"tests": [
{
- "text": "steamrollArray([[[\"a\"]], [[\"b\"]]])
should return [\"a\", \"b\"]
.",
- "testString": "assert.deepEqual(steamrollArray([[[\"a\"]], [[\"b\"]]]), [\"a\", \"b\"], 'steamrollArray([[[\"a\"]], [[\"b\"]]])
should return [\"a\", \"b\"]
.');"
+ "text": "steamrollArray([[[\"a\"]], [[\"b\"]]])
should return[\"a\", \"b\"]
.",
+ "testString": "assert.deepEqual(steamrollArray([[[\"a\"]], [[\"b\"]]]), [\"a\", \"b\"], 'steamrollArray([[[\"a\"]], [[\"b\"]]])
should return[\"a\", \"b\"]
.');"
},
{
- "text": "steamrollArray([1, [2], [3, [[4]]]])
should return [1, 2, 3, 4]
.",
- "testString": "assert.deepEqual(steamrollArray([1, [2], [3, [[4]]]]), [1, 2, 3, 4], 'steamrollArray([1, [2], [3, [[4]]]])
should return [1, 2, 3, 4]
.');"
+ "text": "steamrollArray([1, [2], [3, [[4]]]])
should return[1, 2, 3, 4]
.",
+ "testString": "assert.deepEqual(steamrollArray([1, [2], [3, [[4]]]]), [1, 2, 3, 4], 'steamrollArray([1, [2], [3, [[4]]]])
should return[1, 2, 3, 4]
.');"
},
{
- "text": "steamrollArray([1, [], [3, [[4]]]])
should return [1, 3, 4]
.",
- "testString": "assert.deepEqual(steamrollArray([1, [], [3, [[4]]]]), [1, 3, 4], 'steamrollArray([1, [], [3, [[4]]]])
should return [1, 3, 4]
.');"
+ "text": "steamrollArray([1, [], [3, [[4]]]])
should return[1, 3, 4]
.",
+ "testString": "assert.deepEqual(steamrollArray([1, [], [3, [[4]]]]), [1, 3, 4], 'steamrollArray([1, [], [3, [[4]]]])
should return[1, 3, 4]
.');"
},
{
- "text": "steamrollArray([1, {}, [3, [[4]]]])
should return [1, {}, 3, 4]
.",
- "testString": "assert.deepEqual(steamrollArray([1, {}, [3, [[4]]]]), [1, {}, 3, 4], 'steamrollArray([1, {}, [3, [[4]]]])
should return [1, {}, 3, 4]
.');"
+ "text": "steamrollArray([1, {}, [3, [[4]]]])
should return[1, {}, 3, 4]
.",
+ "testString": "assert.deepEqual(steamrollArray([1, {}, [3, [[4]]]]), [1, {}, 3, 4], 'steamrollArray([1, {}, [3, [[4]]]])
should return[1, {}, 3, 4]
.');"
}
],
"MDNlinks": [
@@ -1000,12 +1000,12 @@
],
"tests": [
{
- "text": "binaryAgent(\"01000001 01110010 01100101 01101110 00100111 01110100 00100000 01100010 01101111 01101110 01100110 01101001 01110010 01100101 01110011 00100000 01100110 01110101 01101110 00100001 00111111\")
should return \"Aren't bonfires fun!?\"",
- "testString": "assert.deepEqual(binaryAgent('01000001 01110010 01100101 01101110 00100111 01110100 00100000 01100010 01101111 01101110 01100110 01101001 01110010 01100101 01110011 00100000 01100110 01110101 01101110 00100001 00111111'), \"Aren't bonfires fun!?\", 'binaryAgent(\"01000001 01110010 01100101 01101110 00100111 01110100 00100000 01100010 01101111 01101110 01100110 01101001 01110010 01100101 01110011 00100000 01100110 01110101 01101110 00100001 00111111\")
should return \"Aren't bonfires fun!?\"');"
+ "text": "binaryAgent(\"01000001 01110010 01100101 01101110 00100111 01110100 00100000 01100010 01101111 01101110 01100110 01101001 01110010 01100101 01110011 00100000 01100110 01110101 01101110 00100001 00111111\")
should return \"Aren't bonfires fun!?\"",
+ "testString": "assert.deepEqual(binaryAgent('01000001 01110010 01100101 01101110 00100111 01110100 00100000 01100010 01101111 01101110 01100110 01101001 01110010 01100101 01110011 00100000 01100110 01110101 01101110 00100001 00111111'), \"Aren't bonfires fun!?\", 'binaryAgent(\"01000001 01110010 01100101 01101110 00100111 01110100 00100000 01100010 01101111 01101110 01100110 01101001 01110010 01100101 01110011 00100000 01100110 01110101 01101110 00100001 00111111\")
should return \"Aren't bonfires fun!?\"');"
},
{
- "text": "binaryAgent(\"01001001 00100000 01101100 01101111 01110110 01100101 00100000 01000110 01110010 01100101 01100101 01000011 01101111 01100100 01100101 01000011 01100001 01101101 01110000 00100001\")
should return \"I love FreeCodeCamp!\"",
- "testString": "assert.deepEqual(binaryAgent('01001001 00100000 01101100 01101111 01110110 01100101 00100000 01000110 01110010 01100101 01100101 01000011 01101111 01100100 01100101 01000011 01100001 01101101 01110000 00100001'), \"I love FreeCodeCamp!\", 'binaryAgent(\"01001001 00100000 01101100 01101111 01110110 01100101 00100000 01000110 01110010 01100101 01100101 01000011 01101111 01100100 01100101 01000011 01100001 01101101 01110000 00100001\")
should return \"I love FreeCodeCamp!\"');"
+ "text": "binaryAgent(\"01001001 00100000 01101100 01101111 01110110 01100101 00100000 01000110 01110010 01100101 01100101 01000011 01101111 01100100 01100101 01000011 01100001 01101101 01110000 00100001\")
should return \"I love FreeCodeCamp!\"",
+ "testString": "assert.deepEqual(binaryAgent('01001001 00100000 01101100 01101111 01110110 01100101 00100000 01000110 01110010 01100101 01100101 01000011 01101111 01100100 01100101 01000011 01100001 01101101 01110000 00100001'), \"I love FreeCodeCamp!\", 'binaryAgent(\"01001001 00100000 01101100 01101111 01110110 01100101 00100000 01000110 01110010 01100101 01100101 01000011 01101111 01100100 01100101 01000011 01100001 01101101 01110000 00100001\")
should return \"I love FreeCodeCamp!\"');"
}
],
"MDNlinks": [
@@ -1036,9 +1036,9 @@
"title": "Everything Be True",
"description": [
"Check if the predicate (second argument) is truthy on all elements of a collection (first argument).",
- "In other words, you are given an array collection of objects. The predicate pre
will be an object property and you need to return true
if its value is truthy
. Otherwise, return false
.",
- "In JavaScript, truthy
values are values that translate to true
when evaluated in a Boolean context.",
- "Remember, you can access object properties through either dot notation or []
notation.",
+ "In other words, you are given an array collection of objects. The predicatepre
will be an object property and you need to returntrue
if its value istruthy
. Otherwise, returnfalse
.",
+ "In JavaScript,truthy
values are values that translate totrue
when evaluated in a Boolean context.",
+ "Remember, you can access object properties through either dot notation or[]
notation.",
"Remember to use Read-Search-Ask if you get stuck. Try to pair program. Write your own code."
],
"solutions": [
@@ -1046,40 +1046,40 @@
],
"tests": [
{
- "text": "truthCheck([{\"user\": \"Tinky-Winky\", \"sex\": \"male\"}, {\"user\": \"Dipsy\", \"sex\": \"male\"}, {\"user\": \"Laa-Laa\", \"sex\": \"female\"}, {\"user\": \"Po\", \"sex\": \"female\"}], \"sex\")
should return true.",
- "testString": "assert.strictEqual(truthCheck([{\"user\": \"Tinky-Winky\", \"sex\": \"male\"}, {\"user\": \"Dipsy\", \"sex\": \"male\"}, {\"user\": \"Laa-Laa\", \"sex\": \"female\"}, {\"user\": \"Po\", \"sex\": \"female\"}], \"sex\"), true, 'truthCheck([{\"user\": \"Tinky-Winky\", \"sex\": \"male\"}, {\"user\": \"Dipsy\", \"sex\": \"male\"}, {\"user\": \"Laa-Laa\", \"sex\": \"female\"}, {\"user\": \"Po\", \"sex\": \"female\"}], \"sex\")
should return true.');"
+ "text": "truthCheck([{\"user\": \"Tinky-Winky\", \"sex\": \"male\"}, {\"user\": \"Dipsy\", \"sex\": \"male\"}, {\"user\": \"Laa-Laa\", \"sex\": \"female\"}, {\"user\": \"Po\", \"sex\": \"female\"}], \"sex\")
should return true.",
+ "testString": "assert.strictEqual(truthCheck([{\"user\": \"Tinky-Winky\", \"sex\": \"male\"}, {\"user\": \"Dipsy\", \"sex\": \"male\"}, {\"user\": \"Laa-Laa\", \"sex\": \"female\"}, {\"user\": \"Po\", \"sex\": \"female\"}], \"sex\"), true, 'truthCheck([{\"user\": \"Tinky-Winky\", \"sex\": \"male\"}, {\"user\": \"Dipsy\", \"sex\": \"male\"}, {\"user\": \"Laa-Laa\", \"sex\": \"female\"}, {\"user\": \"Po\", \"sex\": \"female\"}], \"sex\")
should return true.');"
},
{
- "text": "truthCheck([{\"user\": \"Tinky-Winky\", \"sex\": \"male\"}, {\"user\": \"Dipsy\"}, {\"user\": \"Laa-Laa\", \"sex\": \"female\"}, {\"user\": \"Po\", \"sex\": \"female\"}], \"sex\")
should return false.",
- "testString": "assert.strictEqual(truthCheck([{\"user\": \"Tinky-Winky\", \"sex\": \"male\"}, {\"user\": \"Dipsy\"}, {\"user\": \"Laa-Laa\", \"sex\": \"female\"}, {\"user\": \"Po\", \"sex\": \"female\"}], \"sex\"), false, 'truthCheck([{\"user\": \"Tinky-Winky\", \"sex\": \"male\"}, {\"user\": \"Dipsy\"}, {\"user\": \"Laa-Laa\", \"sex\": \"female\"}, {\"user\": \"Po\", \"sex\": \"female\"}], \"sex\")
should return false.');"
+ "text": "truthCheck([{\"user\": \"Tinky-Winky\", \"sex\": \"male\"}, {\"user\": \"Dipsy\"}, {\"user\": \"Laa-Laa\", \"sex\": \"female\"}, {\"user\": \"Po\", \"sex\": \"female\"}], \"sex\")
should return false.",
+ "testString": "assert.strictEqual(truthCheck([{\"user\": \"Tinky-Winky\", \"sex\": \"male\"}, {\"user\": \"Dipsy\"}, {\"user\": \"Laa-Laa\", \"sex\": \"female\"}, {\"user\": \"Po\", \"sex\": \"female\"}], \"sex\"), false, 'truthCheck([{\"user\": \"Tinky-Winky\", \"sex\": \"male\"}, {\"user\": \"Dipsy\"}, {\"user\": \"Laa-Laa\", \"sex\": \"female\"}, {\"user\": \"Po\", \"sex\": \"female\"}], \"sex\")
should return false.');"
},
{
- "text": "truthCheck([{\"user\": \"Tinky-Winky\", \"sex\": \"male\", \"age\": 0}, {\"user\": \"Dipsy\", \"sex\": \"male\", \"age\": 3}, {\"user\": \"Laa-Laa\", \"sex\": \"female\", \"age\": 5}, {\"user\": \"Po\", \"sex\": \"female\", \"age\": 4}], \"age\")
should return false.",
- "testString": "assert.strictEqual(truthCheck([{\"user\": \"Tinky-Winky\", \"sex\": \"male\", \"age\": 2}, {\"user\": \"Dipsy\", \"sex\": \"male\", \"age\": 0}, {\"user\": \"Laa-Laa\", \"sex\": \"female\", \"age\": 5}, {\"user\": \"Po\", \"sex\": \"female\", \"age\": 4}], \"age\"), false, 'truthCheck([{\"user\": \"Tinky-Winky\", \"sex\": \"male\", \"age\": 0}, {\"user\": \"Dipsy\", \"sex\": \"male\", \"age\": 3}, {\"user\": \"Laa-Laa\", \"sex\": \"female\", \"age\": 5}, {\"user\": \"Po\", \"sex\": \"female\", \"age\": 4}], \"age\")
should return false.');"
+ "text": "truthCheck([{\"user\": \"Tinky-Winky\", \"sex\": \"male\", \"age\": 0}, {\"user\": \"Dipsy\", \"sex\": \"male\", \"age\": 3}, {\"user\": \"Laa-Laa\", \"sex\": \"female\", \"age\": 5}, {\"user\": \"Po\", \"sex\": \"female\", \"age\": 4}], \"age\")
should return false.",
+ "testString": "assert.strictEqual(truthCheck([{\"user\": \"Tinky-Winky\", \"sex\": \"male\", \"age\": 2}, {\"user\": \"Dipsy\", \"sex\": \"male\", \"age\": 0}, {\"user\": \"Laa-Laa\", \"sex\": \"female\", \"age\": 5}, {\"user\": \"Po\", \"sex\": \"female\", \"age\": 4}], \"age\"), false, 'truthCheck([{\"user\": \"Tinky-Winky\", \"sex\": \"male\", \"age\": 0}, {\"user\": \"Dipsy\", \"sex\": \"male\", \"age\": 3}, {\"user\": \"Laa-Laa\", \"sex\": \"female\", \"age\": 5}, {\"user\": \"Po\", \"sex\": \"female\", \"age\": 4}], \"age\")
should return false.');"
},
{
- "text": "truthCheck([{\"name\": \"Pete\", \"onBoat\": true}, {\"name\": \"Repeat\", \"onBoat\": true}, {\"name\": \"FastFoward\", \"onBoat\": null}], \"onBoat\")
should return false",
- "testString": "assert.strictEqual(truthCheck([{\"name\": \"Pete\", \"onBoat\": true}, {\"name\": \"Repeat\", \"onBoat\": true}, {\"name\": \"FastFoward\", \"onBoat\": null}], \"onBoat\"), false, 'truthCheck([{\"name\": \"Pete\", \"onBoat\": true}, {\"name\": \"Repeat\", \"onBoat\": true}, {\"name\": \"FastFoward\", \"onBoat\": null}], \"onBoat\")
should return false');"
+ "text": "truthCheck([{\"name\": \"Pete\", \"onBoat\": true}, {\"name\": \"Repeat\", \"onBoat\": true}, {\"name\": \"FastFoward\", \"onBoat\": null}], \"onBoat\")
should return false",
+ "testString": "assert.strictEqual(truthCheck([{\"name\": \"Pete\", \"onBoat\": true}, {\"name\": \"Repeat\", \"onBoat\": true}, {\"name\": \"FastFoward\", \"onBoat\": null}], \"onBoat\"), false, 'truthCheck([{\"name\": \"Pete\", \"onBoat\": true}, {\"name\": \"Repeat\", \"onBoat\": true}, {\"name\": \"FastFoward\", \"onBoat\": null}], \"onBoat\")
should return false');"
},
{
- "text": "truthCheck([{\"name\": \"Pete\", \"onBoat\": true}, {\"name\": \"Repeat\", \"onBoat\": true, \"alias\": \"Repete\"}, {\"name\": \"FastFoward\", \"onBoat\": true}], \"onBoat\")
should return true",
- "testString": "assert.strictEqual(truthCheck([{\"name\": \"Pete\", \"onBoat\": true}, {\"name\": \"Repeat\", \"onBoat\": true, \"alias\": \"Repete\"}, {\"name\": \"FastFoward\", \"onBoat\": true}], \"onBoat\"), true, 'truthCheck([{\"name\": \"Pete\", \"onBoat\": true}, {\"name\": \"Repeat\", \"onBoat\": true, \"alias\": \"Repete\"}, {\"name\": \"FastFoward\", \"onBoat\": true}], \"onBoat\")
should return true');"
+ "text": "truthCheck([{\"name\": \"Pete\", \"onBoat\": true}, {\"name\": \"Repeat\", \"onBoat\": true, \"alias\": \"Repete\"}, {\"name\": \"FastFoward\", \"onBoat\": true}], \"onBoat\")
should return true",
+ "testString": "assert.strictEqual(truthCheck([{\"name\": \"Pete\", \"onBoat\": true}, {\"name\": \"Repeat\", \"onBoat\": true, \"alias\": \"Repete\"}, {\"name\": \"FastFoward\", \"onBoat\": true}], \"onBoat\"), true, 'truthCheck([{\"name\": \"Pete\", \"onBoat\": true}, {\"name\": \"Repeat\", \"onBoat\": true, \"alias\": \"Repete\"}, {\"name\": \"FastFoward\", \"onBoat\": true}], \"onBoat\")
should return true');"
},
{
- "text": "truthCheck([{\"single\": \"yes\"}], \"single\")
should return true",
- "testString": "assert.strictEqual(truthCheck([{\"single\": \"yes\"}], \"single\"), true, 'truthCheck([{\"single\": \"yes\"}], \"single\")
should return true');"
+ "text": "truthCheck([{\"single\": \"yes\"}], \"single\")
should return true",
+ "testString": "assert.strictEqual(truthCheck([{\"single\": \"yes\"}], \"single\"), true, 'truthCheck([{\"single\": \"yes\"}], \"single\")
should return true');"
},
{
- "text": "truthCheck([{\"single\": \"\"}, {\"single\": \"double\"}], \"single\")
should return false",
- "testString": "assert.strictEqual(truthCheck([{\"single\": \"\"}, {\"single\": \"double\"}], \"single\"), false, 'truthCheck([{\"single\": \"\"}, {\"single\": \"double\"}], \"single\")
should return false');"
+ "text": "truthCheck([{\"single\": \"\"}, {\"single\": \"double\"}], \"single\")
should return false",
+ "testString": "assert.strictEqual(truthCheck([{\"single\": \"\"}, {\"single\": \"double\"}], \"single\"), false, 'truthCheck([{\"single\": \"\"}, {\"single\": \"double\"}], \"single\")
should return false');"
},
{
- "text": "truthCheck([{\"single\": \"double\"}, {\"single\": undefined}], \"single\")
should return false",
- "testString": "assert.strictEqual(truthCheck([{\"single\": \"double\"}, {\"single\": undefined}], \"single\"), false, 'truthCheck([{\"single\": \"double\"}, {\"single\": undefined}], \"single\")
should return false');"
+ "text": "truthCheck([{\"single\": \"double\"}, {\"single\": undefined}], \"single\")
should return false",
+ "testString": "assert.strictEqual(truthCheck([{\"single\": \"double\"}, {\"single\": undefined}], \"single\"), false, 'truthCheck([{\"single\": \"double\"}, {\"single\": undefined}], \"single\")
should return false');"
},
{
- "text": "truthCheck([{\"single\": \"double\"}, {\"single\": NaN}], \"single\")
should return false",
- "testString": "assert.strictEqual(truthCheck([{\"single\": \"double\"}, {\"single\": NaN}], \"single\"), false, 'truthCheck([{\"single\": \"double\"}, {\"single\": NaN}], \"single\")
should return false');"
+ "text": "truthCheck([{\"single\": \"double\"}, {\"single\": NaN}], \"single\")
should return false",
+ "testString": "assert.strictEqual(truthCheck([{\"single\": \"double\"}, {\"single\": NaN}], \"single\"), false, 'truthCheck([{\"single\": \"double\"}, {\"single\": NaN}], \"single\")
should return false');"
}
],
"isRequired": true,
@@ -1111,10 +1111,10 @@
"title": "Arguments Optional",
"description": [
"Create a function that sums two arguments together. If only one argument is provided, then return a function that expects one argument and returns the sum.",
- "For example, addTogether(2, 3)
should return 5
, and addTogether(2)
should return a function.",
+ "For example,addTogether(2, 3)
should return5
, andaddTogether(2)
should return a function.",
"Calling this returned function with a single argument will then return the sum:",
"var sumTwoAnd = addTogether(2);
",
- "sumTwoAnd(3)
returns 5
.",
+ "sumTwoAnd(3)
returns5
.",
"If either argument isn't a valid number, return undefined.",
"Remember to use Read-Search-Ask if you get stuck. Try to pair program. Write your own code."
],
@@ -1123,24 +1123,24 @@
],
"tests": [
{
- "text": "addTogether(2, 3)
should return 5.",
- "testString": "assert.deepEqual(addTogether(2, 3), 5, 'addTogether(2, 3)
should return 5.');"
+ "text": "addTogether(2, 3)
should return 5.",
+ "testString": "assert.deepEqual(addTogether(2, 3), 5, 'addTogether(2, 3)
should return 5.');"
},
{
- "text": "addTogether(2)(3)
should return 5.",
- "testString": "assert.deepEqual(addTogether(2)(3), 5, 'addTogether(2)(3)
should return 5.');"
+ "text": "addTogether(2)(3)
should return 5.",
+ "testString": "assert.deepEqual(addTogether(2)(3), 5, 'addTogether(2)(3)
should return 5.');"
},
{
- "text": "addTogether(\"http://bit.ly/IqT6zt\")
should return undefined.",
- "testString": "assert.isUndefined(addTogether(\"http://bit.ly/IqT6zt\"), 'addTogether(\"http://bit.ly/IqT6zt\")
should return undefined.');"
+ "text": "addTogether(\"http://bit.ly/IqT6zt\")
should return undefined.",
+ "testString": "assert.isUndefined(addTogether(\"http://bit.ly/IqT6zt\"), 'addTogether(\"http://bit.ly/IqT6zt\")
should return undefined.');"
},
{
- "text": "addTogether(2, \"3\")
should return undefined.",
- "testString": "assert.isUndefined(addTogether(2, \"3\"), 'addTogether(2, \"3\")
should return undefined.');"
+ "text": "addTogether(2, \"3\")
should return undefined.",
+ "testString": "assert.isUndefined(addTogether(2, \"3\"), 'addTogether(2, \"3\")
should return undefined.');"
},
{
- "text": "addTogether(2)([3])
should return undefined.",
- "testString": "assert.isUndefined(addTogether(2)([3]), 'addTogether(2)([3])
should return undefined.');"
+ "text": "addTogether(2)([3])
should return undefined.",
+ "testString": "assert.isUndefined(addTogether(2)([3]), 'addTogether(2)([3])
should return undefined.');"
}
],
"MDNlinks": [
@@ -1183,52 +1183,52 @@
],
"tests": [
{
- "text": "Object.keys(bob).length
should return 6.",
- "testString": "assert.deepEqual(Object.keys(bob).length, 6, 'Object.keys(bob).length
should return 6.');"
+ "text": "Object.keys(bob).length
should return 6.",
+ "testString": "assert.deepEqual(Object.keys(bob).length, 6, 'Object.keys(bob).length
should return 6.');"
},
{
- "text": "bob instanceof Person
should return true.",
- "testString": "assert.deepEqual(bob instanceof Person, true, 'bob instanceof Person
should return true.');"
+ "text": "bob instanceof Person
should return true.",
+ "testString": "assert.deepEqual(bob instanceof Person, true, 'bob instanceof Person
should return true.');"
},
{
- "text": "bob.firstName
should return undefined.",
- "testString": "assert.deepEqual(bob.firstName, undefined, 'bob.firstName
should return undefined.');"
+ "text": "bob.firstName
should return undefined.",
+ "testString": "assert.deepEqual(bob.firstName, undefined, 'bob.firstName
should return undefined.');"
},
{
- "text": "bob.lastName
should return undefined.",
- "testString": "assert.deepEqual(bob.lastName, undefined, 'bob.lastName
should return undefined.');"
+ "text": "bob.lastName
should return undefined.",
+ "testString": "assert.deepEqual(bob.lastName, undefined, 'bob.lastName
should return undefined.');"
},
{
- "text": "bob.getFirstName()
should return \"Bob\".",
- "testString": "assert.deepEqual(bob.getFirstName(), 'Bob', 'bob.getFirstName()
should return \"Bob\".');"
+ "text": "bob.getFirstName()
should return \"Bob\".",
+ "testString": "assert.deepEqual(bob.getFirstName(), 'Bob', 'bob.getFirstName()
should return \"Bob\".');"
},
{
- "text": "bob.getLastName()
should return \"Ross\".",
- "testString": "assert.deepEqual(bob.getLastName(), 'Ross', 'bob.getLastName()
should return \"Ross\".');"
+ "text": "bob.getLastName()
should return \"Ross\".",
+ "testString": "assert.deepEqual(bob.getLastName(), 'Ross', 'bob.getLastName()
should return \"Ross\".');"
},
{
- "text": "bob.getFullName()
should return \"Bob Ross\".",
- "testString": "assert.deepEqual(bob.getFullName(), 'Bob Ross', 'bob.getFullName()
should return \"Bob Ross\".');"
+ "text": "bob.getFullName()
should return \"Bob Ross\".",
+ "testString": "assert.deepEqual(bob.getFullName(), 'Bob Ross', 'bob.getFullName()
should return \"Bob Ross\".');"
},
{
- "text": "bob.getFullName()
should return \"Haskell Ross\" after bob.setFirstName(\"Haskell\")
.",
- "testString": "assert.strictEqual((function () { bob.setFirstName(\"Haskell\"); return bob.getFullName(); })(), 'Haskell Ross', 'bob.getFullName()
should return \"Haskell Ross\" after bob.setFirstName(\"Haskell\")
.');"
+ "text": "bob.getFullName()
should return \"Haskell Ross\" afterbob.setFirstName(\"Haskell\")
.",
+ "testString": "assert.strictEqual((function () { bob.setFirstName(\"Haskell\"); return bob.getFullName(); })(), 'Haskell Ross', 'bob.getFullName()
should return \"Haskell Ross\" afterbob.setFirstName(\"Haskell\")
.');"
},
{
- "text": "bob.getFullName()
should return \"Haskell Curry\" after bob.setLastName(\"Curry\")
.",
- "testString": "assert.strictEqual((function () { var _bob=new Person('Haskell Ross'); _bob.setLastName(\"Curry\"); return _bob.getFullName(); })(), 'Haskell Curry', 'bob.getFullName()
should return \"Haskell Curry\" after bob.setLastName(\"Curry\")
.');"
+ "text": "bob.getFullName()
should return \"Haskell Curry\" afterbob.setLastName(\"Curry\")
.",
+ "testString": "assert.strictEqual((function () { var _bob=new Person('Haskell Ross'); _bob.setLastName(\"Curry\"); return _bob.getFullName(); })(), 'Haskell Curry', 'bob.getFullName()
should return \"Haskell Curry\" afterbob.setLastName(\"Curry\")
.');"
},
{
- "text": "bob.getFullName()
should return \"Haskell Curry\" after bob.setFullName(\"Haskell Curry\")
.",
- "testString": "assert.strictEqual((function () { bob.setFullName(\"Haskell Curry\"); return bob.getFullName(); })(), 'Haskell Curry', 'bob.getFullName()
should return \"Haskell Curry\" after bob.setFullName(\"Haskell Curry\")
.');"
+ "text": "bob.getFullName()
should return \"Haskell Curry\" afterbob.setFullName(\"Haskell Curry\")
.",
+ "testString": "assert.strictEqual((function () { bob.setFullName(\"Haskell Curry\"); return bob.getFullName(); })(), 'Haskell Curry', 'bob.getFullName()
should return \"Haskell Curry\" afterbob.setFullName(\"Haskell Curry\")
.');"
},
{
- "text": "bob.getFirstName()
should return \"Haskell\" after bob.setFullName(\"Haskell Curry\")
.",
- "testString": "assert.strictEqual((function () { bob.setFullName(\"Haskell Curry\"); return bob.getFirstName(); })(), 'Haskell', 'bob.getFirstName()
should return \"Haskell\" after bob.setFullName(\"Haskell Curry\")
.');"
+ "text": "bob.getFirstName()
should return \"Haskell\" afterbob.setFullName(\"Haskell Curry\")
.",
+ "testString": "assert.strictEqual((function () { bob.setFullName(\"Haskell Curry\"); return bob.getFirstName(); })(), 'Haskell', 'bob.getFirstName()
should return \"Haskell\" afterbob.setFullName(\"Haskell Curry\")
.');"
},
{
- "text": "bob.getLastName()
should return \"Curry\" after bob.setFullName(\"Haskell Curry\")
.",
- "testString": "assert.strictEqual((function () { bob.setFullName(\"Haskell Curry\"); return bob.getLastName(); })(), 'Curry', 'bob.getLastName()
should return \"Curry\" after bob.setFullName(\"Haskell Curry\")
.');"
+ "text": "bob.getLastName()
should return \"Curry\" afterbob.setFullName(\"Haskell Curry\")
.",
+ "testString": "assert.strictEqual((function () { bob.setFullName(\"Haskell Curry\"); return bob.getLastName(); })(), 'Curry', 'bob.getLastName()
should return \"Curry\" afterbob.setFullName(\"Haskell Curry\")
.');"
}
],
"MDNlinks": [
@@ -1263,7 +1263,7 @@
"title": "Map the Debris",
"description": [
"Return a new array that transforms the elements' average altitude into their orbital periods (in seconds).",
- "The array will contain objects in the format {name: 'name', avgAlt: avgAlt}
.",
+ "The array will contain objects in the format{name: 'name', avgAlt: avgAlt}
.",
"You can read about orbital periods on Wikipedia.",
"The values should be rounded to the nearest whole number. The body being orbited is Earth.",
"The radius of the earth is 6367.4447 kilometers, and the GM value of earth is 398600.4418 km3s-2.",
@@ -1274,12 +1274,12 @@
],
"tests": [
{
- "text": "orbitalPeriod([{name : \"sputnik\", avgAlt : 35873.5553}])
should return [{name: \"sputnik\", orbitalPeriod: 86400}]
.",
- "testString": "assert.deepEqual(orbitalPeriod([{name : \"sputnik\", avgAlt : 35873.5553}]), [{name: \"sputnik\", orbitalPeriod: 86400}], 'orbitalPeriod([{name : \"sputnik\", avgAlt : 35873.5553}])
should return [{name: \"sputnik\", orbitalPeriod: 86400}]
.');"
+ "text": "orbitalPeriod([{name : \"sputnik\", avgAlt : 35873.5553}])
should return[{name: \"sputnik\", orbitalPeriod: 86400}]
.",
+ "testString": "assert.deepEqual(orbitalPeriod([{name : \"sputnik\", avgAlt : 35873.5553}]), [{name: \"sputnik\", orbitalPeriod: 86400}], 'orbitalPeriod([{name : \"sputnik\", avgAlt : 35873.5553}])
should return[{name: \"sputnik\", orbitalPeriod: 86400}]
.');"
},
{
- "text": "orbitalPeriod([{name: \"iss\", avgAlt: 413.6}, {name: \"hubble\", avgAlt: 556.7}, {name: \"moon\", avgAlt: 378632.553}])
should return [{name : \"iss\", orbitalPeriod: 5557}, {name: \"hubble\", orbitalPeriod: 5734}, {name: \"moon\", orbitalPeriod: 2377399}]
.",
- "testString": "assert.deepEqual(orbitalPeriod([{name: \"iss\", avgAlt: 413.6}, {name: \"hubble\", avgAlt: 556.7}, {name: \"moon\", avgAlt: 378632.553}]), [{name : \"iss\", orbitalPeriod: 5557}, {name: \"hubble\", orbitalPeriod: 5734}, {name: \"moon\", orbitalPeriod: 2377399}], 'orbitalPeriod([{name: \"iss\", avgAlt: 413.6}, {name: \"hubble\", avgAlt: 556.7}, {name: \"moon\", avgAlt: 378632.553}])
should return [{name : \"iss\", orbitalPeriod: 5557}, {name: \"hubble\", orbitalPeriod: 5734}, {name: \"moon\", orbitalPeriod: 2377399}]
.');"
+ "text": "orbitalPeriod([{name: \"iss\", avgAlt: 413.6}, {name: \"hubble\", avgAlt: 556.7}, {name: \"moon\", avgAlt: 378632.553}])
should return[{name : \"iss\", orbitalPeriod: 5557}, {name: \"hubble\", orbitalPeriod: 5734}, {name: \"moon\", orbitalPeriod: 2377399}]
.",
+ "testString": "assert.deepEqual(orbitalPeriod([{name: \"iss\", avgAlt: 413.6}, {name: \"hubble\", avgAlt: 556.7}, {name: \"moon\", avgAlt: 378632.553}]), [{name : \"iss\", orbitalPeriod: 5557}, {name: \"hubble\", orbitalPeriod: 5734}, {name: \"moon\", orbitalPeriod: 2377399}], 'orbitalPeriod([{name: \"iss\", avgAlt: 413.6}, {name: \"hubble\", avgAlt: 556.7}, {name: \"moon\", avgAlt: 378632.553}])
should return[{name : \"iss\", orbitalPeriod: 5557}, {name: \"hubble\", orbitalPeriod: 5734}, {name: \"moon\", orbitalPeriod: 2377399}]
.');"
}
],
"MDNlinks": [
diff --git a/06-information-security-and-quality-assurance/information-security-with-helmetjs.json b/06-information-security-and-quality-assurance/information-security-with-helmetjs.json
index 6eda557..8037802 100644
--- a/06-information-security-and-quality-assurance/information-security-with-helmetjs.json
+++ b/06-information-security-and-quality-assurance/information-security-with-helmetjs.json
@@ -8,8 +8,8 @@
"id": "587d8247367417b2b2512c36",
"title": "Install and Require Helmet",
"description": [
- "注意,本项目在 这个 Glitch 项目 的基础上进行开发。你也可以从 GitHub 上克隆。",
- "Helmet 通过配置不同的 HTTP 头部信息来使你的 Express 应用更加安全。安装,并引入 Helmet 这个包。"
+ "注意,本项目在这个 Glitch 项目的基础上进行开发。你也可以从 GitHub 上克隆。",
+ "Helmet 通过配置不同的 HTTP 头部信息来使你的 Express 应用更加安全。在这个挑战中,请安装并引入 Helmet 这个包。"
],
"tests": [
{
@@ -26,8 +26,8 @@
"id": "587d8247367417b2b2512c37",
"title": "Hide Potentially Dangerous Information Using helmet.hidePoweredBy()",
"description": [
- "温馨提醒,本项目在 这个 Glitch 项目 的基础上进行开发。你也可以从 GitHub 上克隆。",
- "如果黑客发现你的网站是用 Express 搭建的,那么他们就可以利用 Express 或 Node 现存的漏洞来攻击你的网站。X-Powered-By: Express
默认情况下会被添加到所有响应的头部。不过 helmet.hidePoweredBy() 中间件可以帮你移除 X-Powered-By 头。你甚至可以把头设置成其它的值。 如 app.use(helmet.hidePoweredBy({ setTo: 'PHP 4.2.0' }))
"
+ "温馨提醒,本项目在这个 Glitch 项目的基础上进行开发。你也可以从 GitHub 上克隆。",
+ "如果黑客发现你的网站是用 Express 搭建的,那么他们就可以利用 Express 或 Node 现存的漏洞来攻击你的网站。X-Powered-By: Express
默认情况下会被添加到所有响应的头部。不过helmet.hidePoweredBy()
中间件可以帮你移除X-Powered-By
头。你甚至可以把头设置成其它的值。 如app.use(helmet.hidePoweredBy({ setTo: 'PHP 4.2.0' }))
。"
],
"tests": [
{
@@ -44,17 +44,17 @@
"id": "587d8247367417b2b2512c38",
"title": "Mitigate the Risk of Clickjacking with helmet.frameguard()",
"description": [
- "温馨提醒,本项目在 这个 Glitch 项目 的基础上进行开发。你也可以从 GitHub 上克隆。",
- "黑客可能会不经过你的允许,把你的页面嵌套在 或者