From f78814b6c5cf1c70992e629531065b256eb95bca Mon Sep 17 00:00:00 2001
From: LynnLian
Date: Sat, 21 Jul 2018 01:47:17 +0200
Subject: [PATCH 01/26] Progress: 1 / 22 id: 5a858944d96184f06fd60d61 title:
Create Your First CSS Grid
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 翻译description,test
---
01-responsive-web-design/css-grid.json | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/01-responsive-web-design/css-grid.json b/01-responsive-web-design/css-grid.json
index 159f623..824e44f 100644
--- a/01-responsive-web-design/css-grid.json
+++ b/01-responsive-web-design/css-grid.json
@@ -8,14 +8,14 @@
"id": "5a858944d96184f06fd60d61",
"title": "Create Your First CSS Grid",
"description": [
- "Turn any HTML element into a grid container by setting its display
property to grid
. This gives you the ability to use all the other properties associated with CSS Grid.",
- "Note
In CSS Grid, the parent element is referred to as the container and its children are called items.",
+ "为了令 HTML 元素包含在网格容器中,可将 display
的属性值设置为 grid
。此后,你将可以使用关于 CSS 的不同网格特性。",
+ "敲黑板:
在 CSS 网格中, 父元素可被视为 container 。那么他的子元素被称为 items 。",
"
container
class to grid
."
+ "在包含以 container
为 class 的 div 中 ,把其中的 display 属性值设置为 grid。"
],
"tests": [
{
- "text": "container
class should have a display
property with a value of grid
.",
+ "text": "在名为 container
的 class 中,其 display
属性值应被设置为 grid
。",
"testString": "assert(code.match(/.container\\s*?{[\\s\\S]*display\\s*?:\\s*?grid\\s*?;[\\s\\S]*}/gi), 'container
class should have a display
property with a value of grid
.');"
}
],
From 41acf6f66fc4cf4799750d6858580b1abb458bf3 Mon Sep 17 00:00:00 2001
From: LynnLian
Date: Sat, 21 Jul 2018 18:15:39 +0200
Subject: [PATCH 02/26] Progress: 1 / 22 id: 5a858944d96184f06fd60d61 title:
Create Your First CSS Grid
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 修改了上一 pull request 的语法及标点问题。
---
01-responsive-web-design/css-grid.json | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/01-responsive-web-design/css-grid.json b/01-responsive-web-design/css-grid.json
index 824e44f..611ddd7 100644
--- a/01-responsive-web-design/css-grid.json
+++ b/01-responsive-web-design/css-grid.json
@@ -8,15 +8,15 @@
"id": "5a858944d96184f06fd60d61",
"title": "Create Your First CSS Grid",
"description": [
- "为了令 HTML 元素包含在网格容器中,可将 display
的属性值设置为 grid
。此后,你将可以使用关于 CSS 的不同网格特性。",
- "敲黑板:display
的属性值设置为 grid
,那么它就成为了一个网格容器。然后,你就可以调用 CSS 网格的其他属性。",
+ "注意container
为 class 的 div 中 ,把其中的 display 属性值设置为 grid。"
+ "在 class 为 container
的 div 中,把其中的 display 属性值设置为 grid
。"
],
"tests": [
{
- "text": "在名为 container
的 class 中,其 display
属性值应被设置为 grid
。",
- "testString": "assert(code.match(/.container\\s*?{[\\s\\S]*display\\s*?:\\s*?grid\\s*?;[\\s\\S]*}/gi), 'container
class should have a display
property with a value of grid
.');"
+ "text": "在 class 为 container
的 div 中,把其中的 display 属性值设置为 grid
。",
+ "testString": "assert(code.match(/.container\\s*?{[\\s\\S]*display\\s*?:\\s*?grid\\s*?;[\\s\\S]*}/gi), '在 class 为 container
的 div 中,把其中的 display 属性值设置为 grid
。');"
}
],
"solutions": [],
From 18c8fc735bc3a962b2dd177f12210e1556d13ea8 Mon Sep 17 00:00:00 2001
From: LynnLian
Date: Sat, 21 Jul 2018 22:58:05 +0200
Subject: [PATCH 03/26] Progress: 2 / 22 id: 5a9036d038fddaf9a66b5d32 title:
Add Columns with grid-template-columns
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
- 翻译description, test
---
01-responsive-web-design/css-grid.json | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/01-responsive-web-design/css-grid.json b/01-responsive-web-design/css-grid.json
index 611ddd7..556cc83 100644
--- a/01-responsive-web-design/css-grid.json
+++ b/01-responsive-web-design/css-grid.json
@@ -64,17 +64,17 @@
"id": "5a9036d038fddaf9a66b5d32",
"title": "Add Columns with grid-template-columns",
"description": [
- "Simply creating a grid element doesn't get you very far. You need to define the structure of the grid as well. To add some columns to the grid, use the grid-template-columns
property on a grid container as demonstrated below:",
+ "简单地创建一个网格元素并不能取得很大的进展。你还需要明确网格的结构。在一个容器中使用 grid-template-columns
属性可以添加一些列,实列如下:",
".container {", - "This will give your grid two columns that are 50px wide each.", - "The number of parameters given to the
display: grid;
grid-template-columns: 50px 50px;
}
grid-template-columns
property indicates the number of columns in the grid, and the value of each parameter indicates the width of each column.",
+ "上面的代码可以在网格容器中添加两列,宽度均为 50px。",
+ "在 grid-template-columns
属性中,参数的个数代表列的个数,参数的值代表列的宽度。",
"100px
wide each."
+ "在容器中设置三个列,每列宽度为 100px
。"
],
"tests": [
{
- "text": "container
class should have a grid-template-columns
property with three units of 100px
.",
- "testString": "assert(code.match(/.container\\s*?{[\\s\\S]*grid-template-columns\\s*?:\\s*?100px\\s*?100px\\s*?100px\\s*?;[\\s\\S]*}/gi), 'container
class should have a grid-template-columns
property with three units of 100px
.');"
+ "text": "在容器中应该有三个列,而且每列宽度为 100px
。",
+ "testString": "assert(code.match(/.container\\s*?{[\\s\\S]*grid-template-columns\\s*?:\\s*?100px\\s*?100px\\s*?100px\\s*?;[\\s\\S]*}/gi), '在容器中应该有三个列,而且每列宽度为 100px
。');"
}
],
"solutions": [],
From 8aca09a98ecaf30ee4aece5bf67de49eb1ff2243 Mon Sep 17 00:00:00 2001
From: LynnLian
Date: Sun, 22 Jul 2018 01:20:28 +0200
Subject: [PATCH 04/26] =?UTF-8?q?=E6=8C=89=E4=BB=A5=E4=B8=8B=E8=A7=84?=
=?UTF-8?q?=E5=88=99=E4=BF=AE=E6=94=B9=E7=94=A8=E8=AF=8D=EF=BC=9A=20use=20?=
=?UTF-8?q?=3D>=20=E4=BD=BF=E7=94=A8=20call=20=3D>=20=E8=B0=83=E7=94=A8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
01-responsive-web-design/css-grid.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/01-responsive-web-design/css-grid.json b/01-responsive-web-design/css-grid.json
index 556cc83..1d9f617 100644
--- a/01-responsive-web-design/css-grid.json
+++ b/01-responsive-web-design/css-grid.json
@@ -8,7 +8,7 @@
"id": "5a858944d96184f06fd60d61",
"title": "Create Your First CSS Grid",
"description": [
- "对于任何 HTML 元素,如果我们把它的 display
的属性值设置为 grid
,那么它就成为了一个网格容器。然后,你就可以调用 CSS 网格的其他属性。",
+ "对于任何 HTML 元素,如果我们把它的 display
的属性值设置为 grid
,那么它就成为了一个网格容器。然后,你就可以使用 CSS 网格的其他属性。",
"注意container
的 div 中,把其中的 display 属性值设置为 grid
。"
From 6f6a5634f3aba2a9e6a57f8a475877103e627744 Mon Sep 17 00:00:00 2001
From: LynnLian
Date: Sun, 22 Jul 2018 12:11:32 +0200
Subject: [PATCH 05/26] =?UTF-8?q?=E7=AE=97=E6=B3=95=E5=92=8C=E6=95=B0?=
=?UTF-8?q?=E6=8D=AE=E7=BB=93=E6=9E=84=20-=20=E9=A1=B9=E7=9B=AE=E5=AE=9E?=
=?UTF-8?q?=E8=B7=B5=20=EF=BC=881/5)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Palindrome Checker
- 翻译description,test
---
...gorithms-and-data-structures-projects.json | 64 +++++++++----------
1 file changed, 32 insertions(+), 32 deletions(-)
diff --git a/02-javascript-algorithms-and-data-structures/javascript-algorithms-and-data-structures-projects.json b/02-javascript-algorithms-and-data-structures/javascript-algorithms-and-data-structures-projects.json
index 7170145..a982e62 100644
--- a/02-javascript-algorithms-and-data-structures/javascript-algorithms-and-data-structures-projects.json
+++ b/02-javascript-algorithms-and-data-structures/javascript-algorithms-and-data-structures-projects.json
@@ -8,65 +8,65 @@
"id": "aaa48de84e1ecc7c742e1124",
"title": "Palindrome Checker",
"description": [
- "Return true
if the given string is a palindrome. Otherwise, return false
.",
- "A palindrome is a word or sentence that's spelled the same way both forward and backward, ignoring punctuation, case, and spacing.",
- "Note\"racecar\"
, \"RaceCar\"
, and \"race CAR\"
among others.",
- "We'll also pass strings with special symbols, such as \"2A3*3a2\"
, \"2A3 3a2\"
, and \"2_A3*3#A2\"
.",
- "Remember to use Read-Search-Ask if you get stuck. Write your own code."
+ "如果给定的一个字符串是回文,那么返回 true, 否则返回 false。",
+ "回文 指在忽略标点符号、大小写和空格的前提下,将一个词语或句子按相反的顺序重新排列后,所得到的结果和原来的一样。",
+ "注意\"racecar\"
,\"RaceCar\"
,\"race CAR\"
等等。",
+ "我们也会传递一些包含特殊符号的字符串,例如 \"2A3*3a2\"
,\"2A3 3a2\"
和 \"2_A3*3#A2\"
。",
+ "当你遇到困难时,请记得浏览 Read-Search-Ask。然后,编写属于你自己的代码。"
],
"tests": [
{
- "text": "palindrome(\"eye\")
should return a boolean.",
- "testString": "assert(typeof palindrome(\"eye\") === \"boolean\", 'palindrome(\"eye\")
should return a boolean.');"
+ "text": "palindrome(\"eye\")
应该返回一个布尔值。",
+ "testString": "assert(typeof palindrome(\"eye\") === \"boolean\", 'palindrome(\"eye\")
应该返回一个布尔值。');"
},
{
- "text": "palindrome(\"eye\")
should return true.",
- "testString": "assert(palindrome(\"eye\") === true, 'palindrome(\"eye\")
should return true.');"
+ "text": "palindrome(\"eye\")
应该返回 true。",
+ "testString": "assert(palindrome(\"eye\") === true, 'palindrome(\"eye\")
应该返回 true。');"
},
{
- "text": "palindrome(\"_eye\")
should return true.",
- "testString": "assert(palindrome(\"_eye\") === true, 'palindrome(\"_eye\")
should return true.');"
+ "text": "palindrome(\"_eye\")
应该返回 true。",
+ "testString": "assert(palindrome(\"_eye\") === true, 'palindrome(\"_eye\")
应该返回 true。');"
},
{
- "text": "palindrome(\"race car\")
should return true.",
- "testString": "assert(palindrome(\"race car\") === true, 'palindrome(\"race car\")
should return true.');"
+ "text": "palindrome(\"race car\")
应该返回 true。",
+ "testString": "assert(palindrome(\"race car\") === true, 'palindrome(\"race car\")
应该返回 true。');"
},
{
- "text": "palindrome(\"not a palindrome\")
should return false.",
- "testString": "assert(palindrome(\"not a palindrome\") === false, 'palindrome(\"not a palindrome\")
should return false.');"
+ "text": "palindrome(\"not a palindrome\")
应该返回 false。",
+ "testString": "assert(palindrome(\"not a palindrome\") === false, 'palindrome(\"not a palindrome\")
应该返回 false。');"
},
{
- "text": "palindrome(\"A man, a plan, a canal. Panama\")
should return true.",
- "testString": "assert(palindrome(\"A man, a plan, a canal. Panama\") === true, 'palindrome(\"A man, a plan, a canal. Panama\")
should return true.');"
+ "text": "palindrome(\"A man, a plan, a canal. Panama\")
应该返回 true。",
+ "testString": "assert(palindrome(\"A man, a plan, a canal. Panama\") === true, 'palindrome(\"A man, a plan, a canal. Panama\")
应该返回 true。');"
},
{
- "text": "palindrome(\"never odd or even\")
should return true.",
- "testString": "assert(palindrome(\"never odd or even\") === true, 'palindrome(\"never odd or even\")
should return true.');"
+ "text": "palindrome(\"never odd or even\")
应该返回 true。",
+ "testString": "assert(palindrome(\"never odd or even\") === true, 'palindrome(\"never odd or even\")
应该返回 true。');"
},
{
- "text": "palindrome(\"nope\")
should return false.",
- "testString": "assert(palindrome(\"nope\") === false, 'palindrome(\"nope\")
should return false.');"
+ "text": "palindrome(\"nope\")
应该返回 false。",
+ "testString": "assert(palindrome(\"nope\") === false, 'palindrome(\"nope\")
应该返回 false。');"
},
{
- "text": "palindrome(\"almostomla\")
should return false.",
- "testString": "assert(palindrome(\"almostomla\") === false, 'palindrome(\"almostomla\")
should return false.');"
+ "text": "palindrome(\"almostomla\")
应该返回 false。",
+ "testString": "assert(palindrome(\"almostomla\") === false, 'palindrome(\"almostomla\")
应该返回 false。');"
},
{
- "text": "palindrome(\"My age is 0, 0 si ega ym.\")
should return true.",
- "testString": "assert(palindrome(\"My age is 0, 0 si ega ym.\") === true, 'palindrome(\"My age is 0, 0 si ega ym.\")
should return true.');"
+ "text": "palindrome(\"My age is 0, 0 si ega ym.\")
应该返回 true。",
+ "testString": "assert(palindrome(\"My age is 0, 0 si ega ym.\") === true, 'palindrome(\"My age is 0, 0 si ega ym.\")
应该返回 true。');"
},
{
- "text": "palindrome(\"1 eye for of 1 eye.\")
should return false.",
- "testString": "assert(palindrome(\"1 eye for of 1 eye.\") === false, 'palindrome(\"1 eye for of 1 eye.\")
should return false.');"
+ "text": "palindrome(\"1 eye for of 1 eye.\")
应该返回 false。",
+ "testString": "assert(palindrome(\"1 eye for of 1 eye.\") === false, 'palindrome(\"1 eye for of 1 eye.\")
应该返回 false。');"
},
{
- "text": "palindrome(\"0_0 (: /-\\ :) 0-0\")
should return true.",
- "testString": "assert(palindrome(\"0_0 (: /-\\ :) 0-0\") === true, 'palindrome(\"0_0 (: /-\\ :) 0-0\")
should return true.');"
+ "text": "palindrome(\"0_0 (: /-\\ :) 0-0\")
应该返回 true。",
+ "testString": "assert(palindrome(\"0_0 (: /-\\ :) 0-0\") === true, 'palindrome(\"0_0 (: /-\\ :) 0-0\")
应该返回 true。');"
},
{
- "text": "palindrome(\"five|\\_/|four\")
should return false.",
- "testString": "assert(palindrome(\"five|\\_/|four\") === false, 'palindrome(\"five|\\_/|four\")
should return false.');"
+ "text": "palindrome(\"five|\\_/|four\")
应该返回 false。",
+ "testString": "assert(palindrome(\"five|\\_/|four\") === false, 'palindrome(\"five|\\_/|four\")
应该返回 false。');"
}
],
"isRequired": true,
From d47c172fe907588283f3d5a987bde960284e9873 Mon Sep 17 00:00:00 2001
From: LynnLian
Date: Sun, 22 Jul 2018 15:44:18 +0200
Subject: [PATCH 06/26] =?UTF-8?q?=E7=AE=97=E6=B3=95=E5=92=8C=E6=95=B0?=
=?UTF-8?q?=E6=8D=AE=E7=BB=93=E6=9E=84=20-=20=E9=A1=B9=E7=9B=AE=E5=AE=9E?=
=?UTF-8?q?=E8=B7=B5=20=EF=BC=882/5)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Roman Numeral Converter
- 翻译description,test
---
...gorithms-and-data-structures-projects.json | 110 +++++++++---------
1 file changed, 55 insertions(+), 55 deletions(-)
diff --git a/02-javascript-algorithms-and-data-structures/javascript-algorithms-and-data-structures-projects.json b/02-javascript-algorithms-and-data-structures/javascript-algorithms-and-data-structures-projects.json
index a982e62..2e6daa1 100644
--- a/02-javascript-algorithms-and-data-structures/javascript-algorithms-and-data-structures-projects.json
+++ b/02-javascript-algorithms-and-data-structures/javascript-algorithms-and-data-structures-projects.json
@@ -102,117 +102,117 @@
"id": "a7f4d8f2483413a6ce226cac",
"title": "Roman Numeral Converter",
"description": [
- "Convert the given number into a roman numeral.",
- "All roman numerals answers should be provided in upper-case.",
- "Remember to use Read-Search-Ask if you get stuck. Try to pair program. Write your own code."
+ "把给定的数字转变为罗马数字。",
+ "所有为罗马数字的答案都必须是字母大写。",
+ "当你遇到困难时,请记得浏览 Read-Search-Ask。你可以尝试结伴编程,但请编写属于你自己的代码。 "
],
"solutions": [
"function convertToRoman(num) {\n var ref = [['M', 1000], ['CM', 900], ['D', 500], ['CD', 400], ['C', 100], ['XC', 90], ['L', 50], ['XL', 40], ['X', 10], ['IX', 9], ['V', 5], ['IV', 4], ['I', 1]];\n var res = [];\n ref.forEach(function(p) {\n while (num >= p[1]) {\n res.push(p[0]);\n num -= p[1];\n }\n });\n return res.join('');\n}"
],
"tests": [
{
- "text": "convertToRoman(2)
should return \"II\".",
- "testString": "assert.deepEqual(convertToRoman(2), \"II\", 'convertToRoman(2)
should return \"II\".');"
+ "text": "convertToRoman(2)
应该返回 \"II\".",
+ "testString": "assert.deepEqual(convertToRoman(2), \"II\", 'convertToRoman(2)
应该返回 \"II\".');"
},
{
- "text": "convertToRoman(3)
should return \"III\".",
- "testString": "assert.deepEqual(convertToRoman(3), \"III\", 'convertToRoman(3)
should return \"III\".');"
+ "text": "convertToRoman(3)
应该返回 \"III\".",
+ "testString": "assert.deepEqual(convertToRoman(3), \"III\", 'convertToRoman(3)
应该返回 \"III\".');"
},
{
- "text": "convertToRoman(4)
should return \"IV\".",
- "testString": "assert.deepEqual(convertToRoman(4), \"IV\", 'convertToRoman(4)
should return \"IV\".');"
+ "text": "convertToRoman(4)
应该返回 \"IV\".",
+ "testString": "assert.deepEqual(convertToRoman(4), \"IV\", 'convertToRoman(4)
应该返回 \"IV\".');"
},
{
- "text": "convertToRoman(5)
should return \"V\".",
- "testString": "assert.deepEqual(convertToRoman(5), \"V\", 'convertToRoman(5)
should return \"V\".');"
+ "text": "convertToRoman(5)
应该返回 \"V\".",
+ "testString": "assert.deepEqual(convertToRoman(5), \"V\", 'convertToRoman(5)
应该返回 \"V\".');"
},
{
- "text": "convertToRoman(9)
should return \"IX\".",
- "testString": "assert.deepEqual(convertToRoman(9), \"IX\", 'convertToRoman(9)
should return \"IX\".');"
+ "text": "convertToRoman(9)
应该返回 \"IX\".",
+ "testString": "assert.deepEqual(convertToRoman(9), \"IX\", 'convertToRoman(9)
应该返回 \"IX\".');"
},
{
- "text": "convertToRoman(12)
should return \"XII\".",
- "testString": "assert.deepEqual(convertToRoman(12), \"XII\", 'convertToRoman(12)
should return \"XII\".');"
+ "text": "convertToRoman(12)
应该返回 \"XII\".",
+ "testString": "assert.deepEqual(convertToRoman(12), \"XII\", 'convertToRoman(12)
应该返回 \"XII\".');"
},
{
- "text": "convertToRoman(16)
should return \"XVI\".",
- "testString": "assert.deepEqual(convertToRoman(16), \"XVI\", 'convertToRoman(16)
should return \"XVI\".');"
+ "text": "convertToRoman(16)
应该返回 \"XVI\".",
+ "testString": "assert.deepEqual(convertToRoman(16), \"XVI\", 'convertToRoman(16)
应该返回 \"XVI\".');"
},
{
- "text": "convertToRoman(29)
should return \"XXIX\".",
- "testString": "assert.deepEqual(convertToRoman(29), \"XXIX\", 'convertToRoman(29)
should return \"XXIX\".');"
+ "text": "convertToRoman(29)
应该返回 \"XXIX\".",
+ "testString": "assert.deepEqual(convertToRoman(29), \"XXIX\", 'convertToRoman(29)
应该返回 \"XXIX\".');"
},
{
- "text": "convertToRoman(44)
should return \"XLIV\".",
- "testString": "assert.deepEqual(convertToRoman(44), \"XLIV\", 'convertToRoman(44)
should return \"XLIV\".');"
+ "text": "convertToRoman(44)
应该返回 \"XLIV\".",
+ "testString": "assert.deepEqual(convertToRoman(44), \"XLIV\", 'convertToRoman(44)
应该返回 \"XLIV\".');"
},
{
- "text": "convertToRoman(45)
should return \"XLV\"",
- "testString": "assert.deepEqual(convertToRoman(45), \"XLV\", 'convertToRoman(45)
should return \"XLV\"');"
+ "text": "convertToRoman(45)
应该返回 \"XLV\"",
+ "testString": "assert.deepEqual(convertToRoman(45), \"XLV\", 'convertToRoman(45)
应该返回 \"XLV\"');"
},
{
- "text": "convertToRoman(68)
should return \"LXVIII\"",
- "testString": "assert.deepEqual(convertToRoman(68), \"LXVIII\", 'convertToRoman(68)
should return \"LXVIII\"');"
+ "text": "convertToRoman(68)
应该返回 \"LXVIII\"",
+ "testString": "assert.deepEqual(convertToRoman(68), \"LXVIII\", 'convertToRoman(68)
应该返回 \"LXVIII\"');"
},
{
- "text": "convertToRoman(83)
should return \"LXXXIII\"",
- "testString": "assert.deepEqual(convertToRoman(83), \"LXXXIII\", 'convertToRoman(83)
should return \"LXXXIII\"');"
+ "text": "convertToRoman(83)
应该返回 \"LXXXIII\"",
+ "testString": "assert.deepEqual(convertToRoman(83), \"LXXXIII\", 'convertToRoman(83)
应该返回 \"LXXXIII\"');"
},
{
- "text": "convertToRoman(97)
should return \"XCVII\"",
- "testString": "assert.deepEqual(convertToRoman(97), \"XCVII\", 'convertToRoman(97)
should return \"XCVII\"');"
+ "text": "convertToRoman(97)
应该返回 \"XCVII\"",
+ "testString": "assert.deepEqual(convertToRoman(97), \"XCVII\", 'convertToRoman(97)
应该返回 \"XCVII\"');"
},
{
- "text": "convertToRoman(99)
should return \"XCIX\"",
- "testString": "assert.deepEqual(convertToRoman(99), \"XCIX\", 'convertToRoman(99)
should return \"XCIX\"');"
+ "text": "convertToRoman(99)
应该返回 \"XCIX\"",
+ "testString": "assert.deepEqual(convertToRoman(99), \"XCIX\", 'convertToRoman(99)
应该返回 \"XCIX\"');"
},
{
- "text": "convertToRoman(400)
should return \"CD\"",
- "testString": "assert.deepEqual(convertToRoman(400), \"CD\", 'convertToRoman(400)
should return \"CD\"');"
+ "text": "convertToRoman(400)
应该返回 \"CD\"",
+ "testString": "assert.deepEqual(convertToRoman(400), \"CD\", 'convertToRoman(400)
应该返回 \"CD\"');"
},
{
- "text": "convertToRoman(500)
should return \"D\"",
- "testString": "assert.deepEqual(convertToRoman(500), \"D\", 'convertToRoman(500)
should return \"D\"');"
+ "text": "convertToRoman(500)
应该返回 \"D\"",
+ "testString": "assert.deepEqual(convertToRoman(500), \"D\", 'convertToRoman(500)
应该返回 \"D\"');"
},
{
- "text": "convertToRoman(501)
should return \"DI\"",
- "testString": "assert.deepEqual(convertToRoman(501), \"DI\", 'convertToRoman(501)
should return \"DI\"');"
+ "text": "convertToRoman(501)
应该返回 \"DI\"",
+ "testString": "assert.deepEqual(convertToRoman(501), \"DI\", 'convertToRoman(501)
应该返回 \"DI\"');"
},
{
- "text": "convertToRoman(649)
should return \"DCXLIX\"",
- "testString": "assert.deepEqual(convertToRoman(649), \"DCXLIX\", 'convertToRoman(649)
should return \"DCXLIX\"');"
+ "text": "convertToRoman(649)
应该返回 \"DCXLIX\"",
+ "testString": "assert.deepEqual(convertToRoman(649), \"DCXLIX\", 'convertToRoman(649)
应该返回 \"DCXLIX\"');"
},
{
- "text": "convertToRoman(798)
should return \"DCCXCVIII\"",
- "testString": "assert.deepEqual(convertToRoman(798), \"DCCXCVIII\", 'convertToRoman(798)
should return \"DCCXCVIII\"');"
+ "text": "convertToRoman(798)
应该返回 \"DCCXCVIII\"",
+ "testString": "assert.deepEqual(convertToRoman(798), \"DCCXCVIII\", 'convertToRoman(798)
应该返回 \"DCCXCVIII\"');"
},
{
- "text": "convertToRoman(891)
should return \"DCCCXCI\"",
- "testString": "assert.deepEqual(convertToRoman(891), \"DCCCXCI\", 'convertToRoman(891)
should return \"DCCCXCI\"');"
+ "text": "convertToRoman(891)
应该返回 \"DCCCXCI\"",
+ "testString": "assert.deepEqual(convertToRoman(891), \"DCCCXCI\", 'convertToRoman(891)
应该返回 \"DCCCXCI\"');"
},
{
- "text": "convertToRoman(1000)
should return \"M\"",
- "testString": "assert.deepEqual(convertToRoman(1000), \"M\", 'convertToRoman(1000)
should return \"M\"');"
+ "text": "convertToRoman(1000)
应该返回 \"M\"",
+ "testString": "assert.deepEqual(convertToRoman(1000), \"M\", 'convertToRoman(1000)
应该返回 \"M\"');"
},
{
- "text": "convertToRoman(1004)
should return \"MIV\"",
- "testString": "assert.deepEqual(convertToRoman(1004), \"MIV\", 'convertToRoman(1004)
should return \"MIV\"');"
+ "text": "convertToRoman(1004)
应该返回 \"MIV\"",
+ "testString": "assert.deepEqual(convertToRoman(1004), \"MIV\", 'convertToRoman(1004)
应该返回 \"MIV\"');"
},
{
- "text": "convertToRoman(1006)
should return \"MVI\"",
- "testString": "assert.deepEqual(convertToRoman(1006), \"MVI\", 'convertToRoman(1006)
should return \"MVI\"');"
+ "text": "convertToRoman(1006)
应该返回 \"MVI\"",
+ "testString": "assert.deepEqual(convertToRoman(1006), \"MVI\", 'convertToRoman(1006)
应该返回 \"MVI\"');"
},
{
- "text": "convertToRoman(1023)
should return \"MXXIII\"",
- "testString": "assert.deepEqual(convertToRoman(1023), \"MXXIII\", 'convertToRoman(1023)
should return \"MXXIII\"');"
+ "text": "convertToRoman(1023)
应该返回 \"MXXIII\"",
+ "testString": "assert.deepEqual(convertToRoman(1023), \"MXXIII\", 'convertToRoman(1023)
应该返回 \"MXXIII\"');"
},
{
- "text": "convertToRoman(2014)
should return \"MMXIV\"",
- "testString": "assert.deepEqual(convertToRoman(2014), \"MMXIV\", 'convertToRoman(2014)
should return \"MMXIV\"');"
+ "text": "convertToRoman(2014)
应该返回 \"MMXIV\"",
+ "testString": "assert.deepEqual(convertToRoman(2014), \"MMXIV\", 'convertToRoman(2014)
应该返回 \"MMXIV\"');"
},
{
- "text": "convertToRoman(3999)
should return \"MMMCMXCIX\"",
- "testString": "assert.deepEqual(convertToRoman(3999), \"MMMCMXCIX\", 'convertToRoman(3999)
should return \"MMMCMXCIX\"');"
+ "text": "convertToRoman(3999)
应该返回 \"MMMCMXCIX\"",
+ "testString": "assert.deepEqual(convertToRoman(3999), \"MMMCMXCIX\", 'convertToRoman(3999)
应该返回 \"MMMCMXCIX\"');"
}
],
"MDNlinks": [
From e1f2d8a2745b9f1d103631475397938c8421ed93 Mon Sep 17 00:00:00 2001
From: LynnLian \"racecar\"
,\"RaceCar\"
,\"race CAR\"
等等。",
@@ -104,7 +104,7 @@
"description": [
"把给定的数字转变为罗马数字。",
"所有为罗马数字的答案都必须是字母大写。",
- "当你遇到困难时,请记得浏览 Read-Search-Ask。你可以尝试结伴编程,但请编写属于你自己的代码。 "
+ "当你遇到困难时,请记得浏览 Read-Search-Ask。你可以尝试结伴编程,但请编写属于你自己的代码。"
],
"solutions": [
"function convertToRoman(num) {\n var ref = [['M', 1000], ['CM', 900], ['D', 500], ['CD', 400], ['C', 100], ['XC', 90], ['L', 50], ['XL', 40], ['X', 10], ['IX', 9], ['V', 5], ['IV', 4], ['I', 1]];\n var res = [];\n ref.forEach(function(p) {\n while (num >= p[1]) {\n res.push(p[0]);\n num -= p[1];\n }\n });\n return res.join('');\n}"
@@ -244,31 +244,31 @@
"id": "56533eb9ac21ba0edf2244e2",
"title": "Caesars Cipher",
"description": [
- "One of the simplest and most widely known ciphers is a Caesar cipher
, also known as a shift cipher
. In a shift cipher
the meanings of the letters are shifted by some set amount.",
- "A common modern use is the ROT13 cipher, where the values of the letters are shifted by 13 places. Thus 'A' ↔ 'N', 'B' ↔ 'O' and so on.",
- "Write a function which takes a ROT13 encoded string as input and returns a decoded string.",
- "All letters will be uppercase. Do not transform any non-alphabetic character (i.e. spaces, punctuation), but do pass them on.",
- "Remember to use Read-Search-Ask if you get stuck. Try to pair program. Write your own code."
+ "其中一个最广为人知而且简单的 加密技术 是 凯撒密码
,也被称为 变换加密
。在 变换加密
中,明文中的字母通过按照一个固定数目进行偏移后被替换成新的字母。",
+ "ROT13 是一个被广泛使用的加密技术,明文中的所有字母都被移动 13 位。因此,'A' ↔ 'N', 'B' ↔ 'O' 等等。",
+ "请编写一个函数,用于解密一个被 ROT13 加密的字符串,然后返回解密后的结果。",
+ "所有解密后的字母都必须为字母大写。请不要解密非字母的字符(例如,空格、标点符号),但是你需要转递他们到结果中。",
+ "当你遇到困难时,请记得浏览 Read-Search-Ask。你可以尝试结伴编程,但请编写属于你自己的代码。"
],
"solutions": [
"var lookup = {\n 'A': 'N','B': 'O','C': 'P','D': 'Q',\n 'E': 'R','F': 'S','G': 'T','H': 'U',\n 'I': 'V','J': 'W','K': 'X','L': 'Y',\n 'M': 'Z','N': 'A','O': 'B','P': 'C',\n 'Q': 'D','R': 'E','S': 'F','T': 'G',\n 'U': 'H','V': 'I','W': 'J','X': 'K',\n 'Y': 'L','Z': 'M' \n};\n\nfunction rot13(encodedStr) {\n var codeArr = encodedStr.split(\"\"); // String to Array\n var decodedArr = []; // Your Result goes here\n // Only change code below this line\n \n decodedArr = codeArr.map(function(letter) {\n if(lookup.hasOwnProperty(letter)) {\n letter = lookup[letter];\n }\n return letter;\n });\n\n // Only change code above this line\n return decodedArr.join(\"\"); // Array to String\n}"
],
"tests": [
{
- "text": "rot13(\"SERR PBQR PNZC\")
should decode to FREE CODE CAMP
",
- "testString": "assert(rot13(\"SERR PBQR PNZC\") === \"FREE CODE CAMP\", 'rot13(\"SERR PBQR PNZC\")
should decode to FREE CODE CAMP
');"
+ "text": "rot13(\"SERR PBQR PNZC\")
应解密为 FREE CODE CAMP
。",
+ "testString": "assert(rot13(\"SERR PBQR PNZC\") === \"FREE CODE CAMP\", 'rot13(\"SERR PBQR PNZC\")
应解密为 FREE CODE CAMP
。');"
},
{
- "text": "rot13(\"SERR CVMMN!\")
should decode to FREE PIZZA!
",
- "testString": "assert(rot13(\"SERR CVMMN!\") === \"FREE PIZZA!\", 'rot13(\"SERR CVMMN!\")
should decode to FREE PIZZA!
');"
+ "text": "rot13(\"SERR CVMMN!\")
应解密为 FREE PIZZA!
。",
+ "testString": "assert(rot13(\"SERR CVMMN!\") === \"FREE PIZZA!\", 'rot13(\"SERR CVMMN!\")
应解密为 FREE PIZZA!
。');"
},
{
- "text": "rot13(\"SERR YBIR?\")
should decode to FREE LOVE?
",
- "testString": "assert(rot13(\"SERR YBIR?\") === \"FREE LOVE?\", 'rot13(\"SERR YBIR?\")
should decode to FREE LOVE?
');"
+ "text": "rot13(\"SERR YBIR?\")
应解密为 FREE LOVE?
。",
+ "testString": "assert(rot13(\"SERR YBIR?\") === \"FREE LOVE?\", 'rot13(\"SERR YBIR?\")
应解密为 FREE LOVE?
。');"
},
{
- "text": "rot13(\"GUR DHVPX OEBJA SBK WHZCF BIRE GUR YNML QBT.\")
should decode to THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG.
",
- "testString": "assert(rot13(\"GUR DHVPX OEBJA SBK WHZCF BIRE GUR YNML QBT.\") === \"THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG.\", 'rot13(\"GUR DHVPX OEBJA SBK WHZCF BIRE GUR YNML QBT.\")
should decode to THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG.
');"
+ "text": "rot13(\"GUR DHVPX OEBJA SBK WHZCF BIRE GUR YNML QBT.\")
应解密为 THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG.
。",
+ "testString": "assert(rot13(\"GUR DHVPX OEBJA SBK WHZCF BIRE GUR YNML QBT.\") === \"THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG.\", 'rot13(\"GUR DHVPX OEBJA SBK WHZCF BIRE GUR YNML QBT.\")
应解密为 THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG.
。');"
}
],
"MDNlinks": [
From aa4dae55fac496d7fe0a661e4925ff19ac7a4c73 Mon Sep 17 00:00:00 2001
From: LynnLian \"racecar\"
,\"RaceCar\"
,\"race CAR\"
等等。",
- "我们也会传递一些包含特殊符号的字符串,例如 \"2A3*3a2\"
,\"2A3 3a2\"
和 \"2_A3*3#A2\"
。",
- "当你遇到困难时,请记得浏览 Read-Search-Ask。然后,编写属于你自己的代码。"
+ "注意:\"racecar\"
、\"RaceCar\"
、\"race CAR\"
等等。",
+ "我们也会传入一些包含特殊符号的字符串,例如 \"2A3*3a2\"
,\"2A3 3a2\"
和 \"2_A3*3#A2\"
。",
+ "如果你遇到了问题,请点击帮助。"
],
"tests": [
{
@@ -102,117 +102,117 @@
"id": "a7f4d8f2483413a6ce226cac",
"title": "Roman Numeral Converter",
"description": [
- "把给定的数字转变为罗马数字。",
- "所有为罗马数字的答案都必须是字母大写。",
- "当你遇到困难时,请记得浏览 Read-Search-Ask。你可以尝试结伴编程,但请编写属于你自己的代码。"
+ "把传入的数字转变为罗马数字。",
+ "转换后的罗马数字字母必须都是大写。",
+ "如果你遇到了问题,请点击帮助。"
],
"solutions": [
"function convertToRoman(num) {\n var ref = [['M', 1000], ['CM', 900], ['D', 500], ['CD', 400], ['C', 100], ['XC', 90], ['L', 50], ['XL', 40], ['X', 10], ['IX', 9], ['V', 5], ['IV', 4], ['I', 1]];\n var res = [];\n ref.forEach(function(p) {\n while (num >= p[1]) {\n res.push(p[0]);\n num -= p[1];\n }\n });\n return res.join('');\n}"
],
"tests": [
{
- "text": "convertToRoman(2)
应该返回 \"II\".",
- "testString": "assert.deepEqual(convertToRoman(2), \"II\", 'convertToRoman(2)
应该返回 \"II\".');"
+ "text": "convertToRoman(2)
应该返回 \"II\"。",
+ "testString": "assert.deepEqual(convertToRoman(2), \"II\", 'convertToRoman(2)
应该返回 \"II\"。');"
},
{
- "text": "convertToRoman(3)
应该返回 \"III\".",
- "testString": "assert.deepEqual(convertToRoman(3), \"III\", 'convertToRoman(3)
应该返回 \"III\".');"
+ "text": "convertToRoman(3)
应该返回 \"III\"。",
+ "testString": "assert.deepEqual(convertToRoman(3), \"III\", 'convertToRoman(3)
应该返回 \"III\"。');"
},
{
- "text": "convertToRoman(4)
应该返回 \"IV\".",
- "testString": "assert.deepEqual(convertToRoman(4), \"IV\", 'convertToRoman(4)
应该返回 \"IV\".');"
+ "text": "convertToRoman(4)
应该返回 \"IV\"。",
+ "testString": "assert.deepEqual(convertToRoman(4), \"IV\", 'convertToRoman(4)
应该返回 \"IV\"。');"
},
{
- "text": "convertToRoman(5)
应该返回 \"V\".",
- "testString": "assert.deepEqual(convertToRoman(5), \"V\", 'convertToRoman(5)
应该返回 \"V\".');"
+ "text": "convertToRoman(5)
应该返回 \"V\"。",
+ "testString": "assert.deepEqual(convertToRoman(5), \"V\", 'convertToRoman(5)
应该返回 \"V\"。');"
},
{
- "text": "convertToRoman(9)
应该返回 \"IX\".",
- "testString": "assert.deepEqual(convertToRoman(9), \"IX\", 'convertToRoman(9)
应该返回 \"IX\".');"
+ "text": "convertToRoman(9)
应该返回 \"IX\"。",
+ "testString": "assert.deepEqual(convertToRoman(9), \"IX\", 'convertToRoman(9)
应该返回 \"IX\"。');"
},
{
- "text": "convertToRoman(12)
应该返回 \"XII\".",
- "testString": "assert.deepEqual(convertToRoman(12), \"XII\", 'convertToRoman(12)
应该返回 \"XII\".');"
+ "text": "convertToRoman(12)
应该返回 \"XII\"。",
+ "testString": "assert.deepEqual(convertToRoman(12), \"XII\", 'convertToRoman(12)
应该返回 \"XII\"。');"
},
{
- "text": "convertToRoman(16)
应该返回 \"XVI\".",
- "testString": "assert.deepEqual(convertToRoman(16), \"XVI\", 'convertToRoman(16)
应该返回 \"XVI\".');"
+ "text": "convertToRoman(16)
应该返回 \"XVI\"。",
+ "testString": "assert.deepEqual(convertToRoman(16), \"XVI\", 'convertToRoman(16)
应该返回 \"XVI\"。');"
},
{
- "text": "convertToRoman(29)
应该返回 \"XXIX\".",
- "testString": "assert.deepEqual(convertToRoman(29), \"XXIX\", 'convertToRoman(29)
应该返回 \"XXIX\".');"
+ "text": "convertToRoman(29)
应该返回 \"XXIX\"。",
+ "testString": "assert.deepEqual(convertToRoman(29), \"XXIX\", 'convertToRoman(29)
应该返回 \"XXIX\"。');"
},
{
- "text": "convertToRoman(44)
应该返回 \"XLIV\".",
- "testString": "assert.deepEqual(convertToRoman(44), \"XLIV\", 'convertToRoman(44)
应该返回 \"XLIV\".');"
+ "text": "convertToRoman(44)
应该返回 \"XLIV\"。",
+ "testString": "assert.deepEqual(convertToRoman(44), \"XLIV\", 'convertToRoman(44)
应该返回 \"XLIV\"。');"
},
{
- "text": "convertToRoman(45)
应该返回 \"XLV\"",
- "testString": "assert.deepEqual(convertToRoman(45), \"XLV\", 'convertToRoman(45)
应该返回 \"XLV\"');"
+ "text": "convertToRoman(45)
应该返回 \"XLV\"。",
+ "testString": "assert.deepEqual(convertToRoman(45), \"XLV\", 'convertToRoman(45)
应该返回 \"XLV\"。');"
},
{
- "text": "convertToRoman(68)
应该返回 \"LXVIII\"",
- "testString": "assert.deepEqual(convertToRoman(68), \"LXVIII\", 'convertToRoman(68)
应该返回 \"LXVIII\"');"
+ "text": "convertToRoman(68)
应该返回 \"LXVIII\"。",
+ "testString": "assert.deepEqual(convertToRoman(68), \"LXVIII\", 'convertToRoman(68)
应该返回 \"LXVIII\"。');"
},
{
- "text": "convertToRoman(83)
应该返回 \"LXXXIII\"",
- "testString": "assert.deepEqual(convertToRoman(83), \"LXXXIII\", 'convertToRoman(83)
应该返回 \"LXXXIII\"');"
+ "text": "convertToRoman(83)
应该返回 \"LXXXIII\"。",
+ "testString": "assert.deepEqual(convertToRoman(83), \"LXXXIII\", 'convertToRoman(83)
应该返回 \"LXXXIII\"。');"
},
{
- "text": "convertToRoman(97)
应该返回 \"XCVII\"",
- "testString": "assert.deepEqual(convertToRoman(97), \"XCVII\", 'convertToRoman(97)
应该返回 \"XCVII\"');"
+ "text": "convertToRoman(97)
应该返回 \"XCVII\"。",
+ "testString": "assert.deepEqual(convertToRoman(97), \"XCVII\", 'convertToRoman(97)
应该返回 \"XCVII\"。');"
},
{
- "text": "convertToRoman(99)
应该返回 \"XCIX\"",
- "testString": "assert.deepEqual(convertToRoman(99), \"XCIX\", 'convertToRoman(99)
应该返回 \"XCIX\"');"
+ "text": "convertToRoman(99)
应该返回 \"XCIX\"。",
+ "testString": "assert.deepEqual(convertToRoman(99), \"XCIX\", 'convertToRoman(99)
应该返回 \"XCIX\"。');"
},
{
- "text": "convertToRoman(400)
应该返回 \"CD\"",
- "testString": "assert.deepEqual(convertToRoman(400), \"CD\", 'convertToRoman(400)
应该返回 \"CD\"');"
+ "text": "convertToRoman(400)
应该返回 \"CD\"。",
+ "testString": "assert.deepEqual(convertToRoman(400), \"CD\", 'convertToRoman(400)
应该返回 \"CD\"。');"
},
{
- "text": "convertToRoman(500)
应该返回 \"D\"",
- "testString": "assert.deepEqual(convertToRoman(500), \"D\", 'convertToRoman(500)
应该返回 \"D\"');"
+ "text": "convertToRoman(500)
应该返回 \"D\"。",
+ "testString": "assert.deepEqual(convertToRoman(500), \"D\", 'convertToRoman(500)
应该返回 \"D\"。');"
},
{
- "text": "convertToRoman(501)
应该返回 \"DI\"",
- "testString": "assert.deepEqual(convertToRoman(501), \"DI\", 'convertToRoman(501)
应该返回 \"DI\"');"
+ "text": "convertToRoman(501)
应该返回 \"DI\"。",
+ "testString": "assert.deepEqual(convertToRoman(501), \"DI\", 'convertToRoman(501)
应该返回 \"DI\"。');"
},
{
- "text": "convertToRoman(649)
应该返回 \"DCXLIX\"",
- "testString": "assert.deepEqual(convertToRoman(649), \"DCXLIX\", 'convertToRoman(649)
应该返回 \"DCXLIX\"');"
+ "text": "convertToRoman(649)
应该返回 \"DCXLIX\"。",
+ "testString": "assert.deepEqual(convertToRoman(649), \"DCXLIX\", 'convertToRoman(649)
应该返回 \"DCXLIX\"。');"
},
{
- "text": "convertToRoman(798)
应该返回 \"DCCXCVIII\"",
- "testString": "assert.deepEqual(convertToRoman(798), \"DCCXCVIII\", 'convertToRoman(798)
应该返回 \"DCCXCVIII\"');"
+ "text": "convertToRoman(798)
应该返回 \"DCCXCVIII\"。",
+ "testString": "assert.deepEqual(convertToRoman(798), \"DCCXCVIII\", 'convertToRoman(798)
应该返回 \"DCCXCVIII\"。');"
},
{
- "text": "convertToRoman(891)
应该返回 \"DCCCXCI\"",
- "testString": "assert.deepEqual(convertToRoman(891), \"DCCCXCI\", 'convertToRoman(891)
应该返回 \"DCCCXCI\"');"
+ "text": "convertToRoman(891)
应该返回 \"DCCCXCI\"。",
+ "testString": "assert.deepEqual(convertToRoman(891), \"DCCCXCI\", 'convertToRoman(891)
应该返回 \"DCCCXCI\"。');"
},
{
- "text": "convertToRoman(1000)
应该返回 \"M\"",
- "testString": "assert.deepEqual(convertToRoman(1000), \"M\", 'convertToRoman(1000)
应该返回 \"M\"');"
+ "text": "convertToRoman(1000)
应该返回 \"M\"。",
+ "testString": "assert.deepEqual(convertToRoman(1000), \"M\", 'convertToRoman(1000)
应该返回 \"M\"。');"
},
{
- "text": "convertToRoman(1004)
应该返回 \"MIV\"",
- "testString": "assert.deepEqual(convertToRoman(1004), \"MIV\", 'convertToRoman(1004)
应该返回 \"MIV\"');"
+ "text": "convertToRoman(1004)
应该返回 \"MIV\"。",
+ "testString": "assert.deepEqual(convertToRoman(1004), \"MIV\", 'convertToRoman(1004)
应该返回 \"MIV\"。');"
},
{
- "text": "convertToRoman(1006)
应该返回 \"MVI\"",
- "testString": "assert.deepEqual(convertToRoman(1006), \"MVI\", 'convertToRoman(1006)
应该返回 \"MVI\"');"
+ "text": "convertToRoman(1006)
应该返回 \"MVI\"。",
+ "testString": "assert.deepEqual(convertToRoman(1006), \"MVI\", 'convertToRoman(1006)
应该返回 \"MVI\"。');"
},
{
- "text": "convertToRoman(1023)
应该返回 \"MXXIII\"",
- "testString": "assert.deepEqual(convertToRoman(1023), \"MXXIII\", 'convertToRoman(1023)
应该返回 \"MXXIII\"');"
+ "text": "convertToRoman(1023)
应该返回 \"MXXIII\"。",
+ "testString": "assert.deepEqual(convertToRoman(1023), \"MXXIII\", 'convertToRoman(1023)
应该返回 \"MXXIII\"。');"
},
{
- "text": "convertToRoman(2014)
应该返回 \"MMXIV\"",
- "testString": "assert.deepEqual(convertToRoman(2014), \"MMXIV\", 'convertToRoman(2014)
应该返回 \"MMXIV\"');"
+ "text": "convertToRoman(2014)
应该返回 \"MMXIV\"。",
+ "testString": "assert.deepEqual(convertToRoman(2014), \"MMXIV\", 'convertToRoman(2014)
应该返回 \"MMXIV\"。');"
},
{
- "text": "convertToRoman(3999)
应该返回 \"MMMCMXCIX\"",
- "testString": "assert.deepEqual(convertToRoman(3999), \"MMMCMXCIX\", 'convertToRoman(3999)
应该返回 \"MMMCMXCIX\"');"
+ "text": "convertToRoman(3999)
应该返回 \"MMMCMXCIX\"。",
+ "testString": "assert.deepEqual(convertToRoman(3999), \"MMMCMXCIX\", 'convertToRoman(3999)
应该返回 \"MMMCMXCIX\"。');"
}
],
"MDNlinks": [
@@ -244,31 +244,31 @@
"id": "56533eb9ac21ba0edf2244e2",
"title": "Caesars Cipher",
"description": [
- "其中一个最广为人知而且简单的 加密技术 是 凯撒密码
,也被称为 变换加密
。在 变换加密
中,明文中的字母通过按照一个固定数目进行偏移后被替换成新的字母。",
- "ROT13 是一个被广泛使用的加密技术,明文中的所有字母都被移动 13 位。因此,'A' ↔ 'N', 'B' ↔ 'O' 等等。",
- "请编写一个函数,用于解密一个被 ROT13 加密的字符串,然后返回解密后的结果。",
- "所有解密后的字母都必须为字母大写。请不要解密非字母的字符(例如,空格、标点符号),但是你需要转递他们到结果中。",
- "当你遇到困难时,请记得浏览 Read-Search-Ask。你可以尝试结伴编程,但请编写属于你自己的代码。"
+ "世界上最简单、最著名的密码是凯撒密码
,也叫移位密码
。在移位密码
中,明文中的字母通过按照一个固定数目进行偏移后被替换成新的字母。",
+ "ROT13 是一个被广泛使用的编码技术,明文中的所有字母都被移动 13 位。因此,'A' ↔ 'N', 'B' ↔ 'O' 等等。",
+ "请编写一个函数,用于解码一个被 ROT13 编码的字符串,然后返回解码后的结果。",
+ "所有解码后的字母都必须为字母大写。请不要解码非字母的字符(例如,空格、标点符号),但是你需要转递他们到结果中。",
+ "如果你遇到了问题,请点击帮助。"
],
"solutions": [
"var lookup = {\n 'A': 'N','B': 'O','C': 'P','D': 'Q',\n 'E': 'R','F': 'S','G': 'T','H': 'U',\n 'I': 'V','J': 'W','K': 'X','L': 'Y',\n 'M': 'Z','N': 'A','O': 'B','P': 'C',\n 'Q': 'D','R': 'E','S': 'F','T': 'G',\n 'U': 'H','V': 'I','W': 'J','X': 'K',\n 'Y': 'L','Z': 'M' \n};\n\nfunction rot13(encodedStr) {\n var codeArr = encodedStr.split(\"\"); // String to Array\n var decodedArr = []; // Your Result goes here\n // Only change code below this line\n \n decodedArr = codeArr.map(function(letter) {\n if(lookup.hasOwnProperty(letter)) {\n letter = lookup[letter];\n }\n return letter;\n });\n\n // Only change code above this line\n return decodedArr.join(\"\"); // Array to String\n}"
],
"tests": [
{
- "text": "rot13(\"SERR PBQR PNZC\")
应解密为 FREE CODE CAMP
。",
- "testString": "assert(rot13(\"SERR PBQR PNZC\") === \"FREE CODE CAMP\", 'rot13(\"SERR PBQR PNZC\")
应解密为 FREE CODE CAMP
。');"
+ "text": "rot13(\"SERR PBQR PNZC\")
应解码为 FREE CODE CAMP
。",
+ "testString": "assert(rot13(\"SERR PBQR PNZC\") === \"FREE CODE CAMP\", 'rot13(\"SERR PBQR PNZC\")
应解码为 FREE CODE CAMP
。');"
},
{
- "text": "rot13(\"SERR CVMMN!\")
应解密为 FREE PIZZA!
。",
- "testString": "assert(rot13(\"SERR CVMMN!\") === \"FREE PIZZA!\", 'rot13(\"SERR CVMMN!\")
应解密为 FREE PIZZA!
。');"
+ "text": "rot13(\"SERR CVMMN!\")
应解码为 FREE PIZZA!
。",
+ "testString": "assert(rot13(\"SERR CVMMN!\") === \"FREE PIZZA!\", 'rot13(\"SERR CVMMN!\")
应解码为 FREE PIZZA!
。');"
},
{
- "text": "rot13(\"SERR YBIR?\")
应解密为 FREE LOVE?
。",
- "testString": "assert(rot13(\"SERR YBIR?\") === \"FREE LOVE?\", 'rot13(\"SERR YBIR?\")
应解密为 FREE LOVE?
。');"
+ "text": "rot13(\"SERR YBIR?\")
应解码为 FREE LOVE?
。",
+ "testString": "assert(rot13(\"SERR YBIR?\") === \"FREE LOVE?\", 'rot13(\"SERR YBIR?\")
应解码为 FREE LOVE?
。');"
},
{
- "text": "rot13(\"GUR DHVPX OEBJA SBK WHZCF BIRE GUR YNML QBT.\")
应解密为 THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG.
。",
- "testString": "assert(rot13(\"GUR DHVPX OEBJA SBK WHZCF BIRE GUR YNML QBT.\") === \"THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG.\", 'rot13(\"GUR DHVPX OEBJA SBK WHZCF BIRE GUR YNML QBT.\")
应解密为 THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG.
。');"
+ "text": "rot13(\"GUR DHVPX OEBJA SBK WHZCF BIRE GUR YNML QBT.\")
应解码为 THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG.
。",
+ "testString": "assert(rot13(\"GUR DHVPX OEBJA SBK WHZCF BIRE GUR YNML QBT.\") === \"THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG.\", 'rot13(\"GUR DHVPX OEBJA SBK WHZCF BIRE GUR YNML QBT.\")
应解码为 THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG.
。');"
}
],
"MDNlinks": [
From ae6b6cfa797af0b73353f2d558e62de2ddb92010 Mon Sep 17 00:00:00 2001
From: LynnLian true
if the passed string looks like a valid US phone number.",
- "The user may fill out the form field any way they choose as long as it has the format of a valid US number. The following are examples of valid formats for US numbers (refer to the tests below for other variants):",
+ "传入的字符串是美国电话号码格式就返回 true
。",
+ "只要是美国电话号码的格式,用户可以按照他们的方式填写表单中的电话号码。以下是一些正确的例子(其他格式变形请参考以下例子):",
"555-555-5555", - "For this challenge you will be presented with a string such as
(555)555-5555
(555) 555-5555
555 555 5555
5555555555
1 555 555 5555
800-692-7753
or 8oo-six427676;laskdjf
. Your job is to validate or reject the US phone number based on any combination of the formats provided above. The area code is required. If the country code is provided, you must confirm that the country code is 1
. Return true
if the string is a valid US phone number; otherwise return false
.",
- "Remember to use Read-Search-Ask if you get stuck. Try to pair program. Write your own code."
+ "在这个挑战中,你将会看到例如 code>800-692-7753 或者 8oo-six427676;laskdjf
的号码。你的任务是根据上面不同的格式组合,判断它是否美国号码。区号是必须的。如果提供国家代码,则必须确认国家代码为 1
。如果这是有效的美国电话就返回 true
,否则返回 false
。",
+ "如果你遇到了问题,请点击帮助。"
],
"solutions": [
"var re = /^([+]?1[\\s]?)?((?:[(](?:[2-9]1[02-9]|[2-9][02-8][0-9])[)][\\s]?)|(?:(?:[2-9]1[02-9]|[2-9][02-8][0-9])[\\s.-]?)){1}([2-9]1[02-9]|[2-9][02-9]1|[2-9][02-9]{2}[\\s.-]?){1}([0-9]{4}){1}$/;\n\nfunction telephoneCheck(str) {\n return re.test(str);\n}\n\ntelephoneCheck(\"555-555-5555\");"
],
"tests": [
{
- "text": "telephoneCheck(\"555-555-5555\")
should return a boolean.",
- "testString": "assert(typeof telephoneCheck(\"555-555-5555\") === \"boolean\", 'telephoneCheck(\"555-555-5555\")
should return a boolean.');"
+ "text": "telephoneCheck(\"555-555-5555\")
应该返回布尔值。",
+ "testString": "assert(typeof telephoneCheck(\"555-555-5555\") === \"boolean\", 'telephoneCheck(\"555-555-5555\")
应该返回布尔值。');"
},
{
- "text": "telephoneCheck(\"1 555-555-5555\")
should return true.",
- "testString": "assert(telephoneCheck(\"1 555-555-5555\") === true, 'telephoneCheck(\"1 555-555-5555\")
should return true.');"
+ "text": "telephoneCheck(\"1 555-555-5555\")
应该返回 true。",
+ "testString": "assert(telephoneCheck(\"1 555-555-5555\") === true, 'telephoneCheck(\"1 555-555-5555\")
应该返回 true。');"
},
{
- "text": "telephoneCheck(\"1 (555) 555-5555\")
should return true.",
- "testString": "assert(telephoneCheck(\"1 (555) 555-5555\") === true, 'telephoneCheck(\"1 (555) 555-5555\")
should return true.');"
+ "text": "telephoneCheck(\"1 (555) 555-5555\")
应该返回 true。",
+ "testString": "assert(telephoneCheck(\"1 (555) 555-5555\") === true, 'telephoneCheck(\"1 (555) 555-5555\")
应该返回 true。');"
},
{
- "text": "telephoneCheck(\"5555555555\")
should return true.",
- "testString": "assert(telephoneCheck(\"5555555555\") === true, 'telephoneCheck(\"5555555555\")
should return true.');"
+ "text": "telephoneCheck(\"5555555555\")
应该返回 true。",
+ "testString": "assert(telephoneCheck(\"5555555555\") === true, 'telephoneCheck(\"5555555555\")
应该返回 true。');"
},
{
- "text": "telephoneCheck(\"555-555-5555\")
should return true.",
- "testString": "assert(telephoneCheck(\"555-555-5555\") === true, 'telephoneCheck(\"555-555-5555\")
should return true.');"
+ "text": "telephoneCheck(\"555-555-5555\")
应该返回 true。",
+ "testString": "assert(telephoneCheck(\"555-555-5555\") === true, 'telephoneCheck(\"555-555-5555\")
应该返回 true。');"
},
{
- "text": "telephoneCheck(\"(555)555-5555\")
should return true.",
- "testString": "assert(telephoneCheck(\"(555)555-5555\") === true, 'telephoneCheck(\"(555)555-5555\")
should return true.');"
+ "text": "telephoneCheck(\"(555)555-5555\")
应该返回 true。",
+ "testString": "assert(telephoneCheck(\"(555)555-5555\") === true, 'telephoneCheck(\"(555)555-5555\")
应该返回 true。');"
},
{
- "text": "telephoneCheck(\"1(555)555-5555\")
should return true.",
- "testString": "assert(telephoneCheck(\"1(555)555-5555\") === true, 'telephoneCheck(\"1(555)555-5555\")
should return true.');"
+ "text": "telephoneCheck(\"1(555)555-5555\")
应该返回 true。",
+ "testString": "assert(telephoneCheck(\"1(555)555-5555\") === true, 'telephoneCheck(\"1(555)555-5555\")
应该返回 true。');"
},
{
- "text": "telephoneCheck(\"555-5555\")
should return false.",
- "testString": "assert(telephoneCheck(\"555-5555\") === false, 'telephoneCheck(\"555-5555\")
should return false.');"
+ "text": "telephoneCheck(\"555-5555\")
应该返回 false。",
+ "testString": "assert(telephoneCheck(\"555-5555\") === false, 'telephoneCheck(\"555-5555\")
应该返回 false。');"
},
{
- "text": "telephoneCheck(\"5555555\")
should return false.",
- "testString": "assert(telephoneCheck(\"5555555\") === false, 'telephoneCheck(\"5555555\")
should return false.');"
+ "text": "telephoneCheck(\"5555555\")
应该返回 false。",
+ "testString": "assert(telephoneCheck(\"5555555\") === false, 'telephoneCheck(\"5555555\")
应该返回 false。');"
},
{
- "text": "telephoneCheck(\"1 555)555-5555\")
should return false.",
- "testString": "assert(telephoneCheck(\"1 555)555-5555\") === false, 'telephoneCheck(\"1 555)555-5555\")
should return false.');"
+ "text": "telephoneCheck(\"1 555)555-5555\")
应该返回 false。",
+ "testString": "assert(telephoneCheck(\"1 555)555-5555\") === false, 'telephoneCheck(\"1 555)555-5555\")
应该返回 false。');"
},
{
- "text": "telephoneCheck(\"1 555 555 5555\")
should return true.",
- "testString": "assert(telephoneCheck(\"1 555 555 5555\") === true, 'telephoneCheck(\"1 555 555 5555\")
should return true.');"
+ "text": "telephoneCheck(\"1 555 555 5555\")
应该返回 true。",
+ "testString": "assert(telephoneCheck(\"1 555 555 5555\") === true, 'telephoneCheck(\"1 555 555 5555\")
应该返回 true。');"
},
{
- "text": "telephoneCheck(\"1 456 789 4444\")
should return true.",
- "testString": "assert(telephoneCheck(\"1 456 789 4444\") === true, 'telephoneCheck(\"1 456 789 4444\")
should return true.');"
+ "text": "telephoneCheck(\"1 456 789 4444\")
应该返回 true。",
+ "testString": "assert(telephoneCheck(\"1 456 789 4444\") === true, 'telephoneCheck(\"1 456 789 4444\")
应该返回 true。');"
},
{
- "text": "telephoneCheck(\"123**&!!asdf#\")
should return false.",
- "testString": "assert(telephoneCheck(\"123**&!!asdf#\") === false, 'telephoneCheck(\"123**&!!asdf#\")
should return false.');"
+ "text": "telephoneCheck(\"123**&!!asdf#\")
应该返回 false。",
+ "testString": "assert(telephoneCheck(\"123**&!!asdf#\") === false, 'telephoneCheck(\"123**&!!asdf#\")
应该返回 false。');"
},
{
- "text": "telephoneCheck(\"55555555\")
should return false.",
- "testString": "assert(telephoneCheck(\"55555555\") === false, 'telephoneCheck(\"55555555\")
should return false.');"
+ "text": "telephoneCheck(\"55555555\")
应该返回 false。",
+ "testString": "assert(telephoneCheck(\"55555555\") === false, 'telephoneCheck(\"55555555\")
应该返回 false。');"
},
{
- "text": "telephoneCheck(\"(6054756961)\")
should return false",
- "testString": "assert(telephoneCheck(\"(6054756961)\") === false, 'telephoneCheck(\"(6054756961)\")
should return false');"
+ "text": "telephoneCheck(\"(6054756961)\")
应该返回 false。",
+ "testString": "assert(telephoneCheck(\"(6054756961)\") === false, 'telephoneCheck(\"(6054756961)\")
应该返回 false。');"
},
{
- "text": "telephoneCheck(\"2 (757) 622-7382\")
should return false.",
- "testString": "assert(telephoneCheck(\"2 (757) 622-7382\") === false, 'telephoneCheck(\"2 (757) 622-7382\")
should return false.');"
+ "text": "telephoneCheck(\"2 (757) 622-7382\")
应该返回 false。",
+ "testString": "assert(telephoneCheck(\"2 (757) 622-7382\") === false, 'telephoneCheck(\"2 (757) 622-7382\")
应该返回 false。');"
},
{
- "text": "telephoneCheck(\"0 (757) 622-7382\")
should return false.",
- "testString": "assert(telephoneCheck(\"0 (757) 622-7382\") === false, 'telephoneCheck(\"0 (757) 622-7382\")
should return false.');"
+ "text": "telephoneCheck(\"0 (757) 622-7382\")
应该返回 false。",
+ "testString": "assert(telephoneCheck(\"0 (757) 622-7382\") === false, 'telephoneCheck(\"0 (757) 622-7382\")
应该返回 false。');"
},
{
- "text": "telephoneCheck(\"-1 (757) 622-7382\")
should return false",
- "testString": "assert(telephoneCheck(\"-1 (757) 622-7382\") === false, 'telephoneCheck(\"-1 (757) 622-7382\")
should return false');"
+ "text": "telephoneCheck(\"-1 (757) 622-7382\")
应该返回 false。",
+ "testString": "assert(telephoneCheck(\"-1 (757) 622-7382\") === false, 'telephoneCheck(\"-1 (757) 622-7382\")
应该返回 false。');"
},
{
- "text": "telephoneCheck(\"2 757 622-7382\")
should return false.",
- "testString": "assert(telephoneCheck(\"2 757 622-7382\") === false, 'telephoneCheck(\"2 757 622-7382\")
should return false.');"
+ "text": "telephoneCheck(\"2 757 622-7382\")
应该返回 false。",
+ "testString": "assert(telephoneCheck(\"2 757 622-7382\") === false, 'telephoneCheck(\"2 757 622-7382\")
应该返回 false。');"
},
{
- "text": "telephoneCheck(\"10 (757) 622-7382\")
should return false.",
- "testString": "assert(telephoneCheck(\"10 (757) 622-7382\") === false, 'telephoneCheck(\"10 (757) 622-7382\")
should return false.');"
+ "text": "telephoneCheck(\"10 (757) 622-7382\")
应该返回 false。",
+ "testString": "assert(telephoneCheck(\"10 (757) 622-7382\") === false, 'telephoneCheck(\"10 (757) 622-7382\")
应该返回 false。');"
},
{
- "text": "telephoneCheck(\"27576227382\")
should return false.",
- "testString": "assert(telephoneCheck(\"27576227382\") === false, 'telephoneCheck(\"27576227382\")
should return false.');"
+ "text": "telephoneCheck(\"27576227382\")
应该返回 false。",
+ "testString": "assert(telephoneCheck(\"27576227382\") === false, 'telephoneCheck(\"27576227382\")
应该返回 false。');"
},
{
- "text": "telephoneCheck(\"(275)76227382\")
should return false.",
- "testString": "assert(telephoneCheck(\"(275)76227382\") === false, 'telephoneCheck(\"(275)76227382\")
should return false.');"
+ "text": "telephoneCheck(\"(275)76227382\")
应该返回 false。",
+ "testString": "assert(telephoneCheck(\"(275)76227382\") === false, 'telephoneCheck(\"(275)76227382\")
应该返回 false。');"
},
{
- "text": "telephoneCheck(\"2(757)6227382\")
should return false.",
- "testString": "assert(telephoneCheck(\"2(757)6227382\") === false, 'telephoneCheck(\"2(757)6227382\")
should return false.');"
+ "text": "telephoneCheck(\"2(757)6227382\")
应该返回 false。",
+ "testString": "assert(telephoneCheck(\"2(757)6227382\") === false, 'telephoneCheck(\"2(757)6227382\")
应该返回 false。');"
},
{
- "text": "telephoneCheck(\"2(757)622-7382\")
should return false.",
- "testString": "assert(telephoneCheck(\"2(757)622-7382\") === false, 'telephoneCheck(\"2(757)622-7382\")
should return false.');"
+ "text": "telephoneCheck(\"2(757)622-7382\")
应该返回 false。",
+ "testString": "assert(telephoneCheck(\"2(757)622-7382\") === false, 'telephoneCheck(\"2(757)622-7382\")
应该返回 false。');"
},
{
- "text": "telephoneCheck(\"555)-555-5555\")
should return false.",
- "testString": "assert(telephoneCheck(\"555)-555-5555\") === false, 'telephoneCheck(\"555)-555-5555\")
should return false.');"
+ "text": "telephoneCheck(\"555)-555-5555\")
应该返回 false。",
+ "testString": "assert(telephoneCheck(\"555)-555-5555\") === false, 'telephoneCheck(\"555)-555-5555\")
应该返回 false。');"
},
{
- "text": "telephoneCheck(\"(555-555-5555\")
should return false.",
- "testString": "assert(telephoneCheck(\"(555-555-5555\") === false, 'telephoneCheck(\"(555-555-5555\")
should return false.');"
+ "text": "telephoneCheck(\"(555-555-5555\")
应该返回 false。",
+ "testString": "assert(telephoneCheck(\"(555-555-5555\") === false, 'telephoneCheck(\"(555-555-5555\")
应该返回 false。');"
},
{
- "text": "telephoneCheck(\"(555)5(55?)-5555\")
should return false.",
- "testString": "assert(telephoneCheck(\"(555)5(55?)-5555\") === false, 'telephoneCheck(\"(555)5(55?)-5555\")
should return false.');"
+ "text": "telephoneCheck(\"(555)5(55?)-5555\")
应该返回 false。",
+ "testString": "assert(telephoneCheck(\"(555)5(55?)-5555\") === false, 'telephoneCheck(\"(555)5(55?)-5555\")
应该返回 false。');"
}
],
"MDNlinks": [
From f004ea8278c9fef6e1448713d9670520d3eb9983 Mon Sep 17 00:00:00 2001
From: LynnLian display
的属性值设置为 grid
,那么它就成为了一个网格容器。然后,你就可以使用 CSS 网格的其他属性。",
- "注意display
property to grid
. This gives you the ability to use all the other properties associated with CSS Grid.",
+ "Notecontainer
的 div 中,把其中的 display 属性值设置为 grid
。"
+ "Change the display of the div with the container
class to grid
."
],
"tests": [
{
- "text": "在 class 为 container
的 div 中,把其中的 display 属性值设置为 grid
。",
- "testString": "assert(code.match(/.container\\s*?{[\\s\\S]*display\\s*?:\\s*?grid\\s*?;[\\s\\S]*}/gi), '在 class 为 container
的 div 中,把其中的 display 属性值设置为 grid
。');"
+ "text": "container
class should have a display
property with a value of grid
.",
+ "testString": "assert(code.match(/.container\\s*?{[\\s\\S]*display\\s*?:\\s*?grid\\s*?;[\\s\\S]*}/gi), 'container
class should have a display
property with a value of grid
.');"
}
],
"solutions": [],
@@ -64,17 +64,17 @@
"id": "5a9036d038fddaf9a66b5d32",
"title": "Add Columns with grid-template-columns",
"description": [
- "简单地创建一个网格元素并不能取得很大的进展。你还需要明确网格的结构。在一个容器中使用 grid-template-columns
属性可以添加一些列,实列如下:",
+ "Simply creating a grid element doesn't get you very far. You need to define the structure of the grid as well. To add some columns to the grid, use the grid-template-columns
property on a grid container as demonstrated below:",
".container {", - "上面的代码可以在网格容器中添加两列,宽度均为 50px。", - "在
display: grid;
grid-template-columns: 50px 50px;
}
grid-template-columns
属性中,参数的个数代表列的个数,参数的值代表列的宽度。",
+ "This will give your grid two columns that are 50px wide each.",
+ "The number of parameters given to the grid-template-columns
property indicates the number of columns in the grid, and the value of each parameter indicates the width of each column.",
"100px
。"
+ "Give the grid container three columns that are 100px
wide each."
],
"tests": [
{
- "text": "在容器中应该有三个列,而且每列宽度为 100px
。",
- "testString": "assert(code.match(/.container\\s*?{[\\s\\S]*grid-template-columns\\s*?:\\s*?100px\\s*?100px\\s*?100px\\s*?;[\\s\\S]*}/gi), '在容器中应该有三个列,而且每列宽度为 100px
。');"
+ "text": "container
class should have a grid-template-columns
property with three units of 100px
.",
+ "testString": "assert(code.match(/.container\\s*?{[\\s\\S]*grid-template-columns\\s*?:\\s*?100px\\s*?100px\\s*?100px\\s*?;[\\s\\S]*}/gi), 'container
class should have a grid-template-columns
property with three units of 100px
.');"
}
],
"solutions": [],
From a0a0aefd99996d0ac30eca972c174cc5a84cccaa Mon Sep 17 00:00:00 2001
From: Xing Liu Math.max()
来获取两数中较大的数。",
+ "使用 Math.min()
来获取两数中较小的数。",
+ "注意,既然需要对两数之间的所有数求和,那就先要考虑好如何获取这些数。"
],
"solutions": [
"function sumAll(arr) {\n var sum = 0;\n arr.sort(function(a,b) {return a-b;});\n for (var i = arr[0]; i <= arr[1]; i++) {\n sum += i; \n }\n return sum;\n}"
],
"tests": [
{
- "text": "sumAll([1, 4])
should return a number.",
- "testString": "assert(typeof sumAll([1, 4]) === 'number', 'sumAll([1, 4])
should return a number.');"
+ "text": "sumAll([1, 4])
应该返回一个数字。",
+ "testString": "assert(typeof sumAll([1, 4]) === 'number', 'sumAll([1, 4])
应该返回一个数字。');"
},
{
- "text": "sumAll([1, 4])
should return 10.",
- "testString": "assert.deepEqual(sumAll([1, 4]), 10, 'sumAll([1, 4])
should return 10.');"
+ "text": "sumAll([1, 4])
应该返回 10。",
+ "testString": "assert.deepEqual(sumAll([1, 4]), 10, 'sumAll([1, 4])
应该返回 10。');"
},
{
- "text": "sumAll([4, 1])
should return 10.",
- "testString": "assert.deepEqual(sumAll([4, 1]), 10, 'sumAll([4, 1])
should return 10.');"
+ "text": "sumAll([4, 1])
应该返回 10。",
+ "testString": "assert.deepEqual(sumAll([4, 1]), 10, 'sumAll([4, 1])
应该返回 10。');"
},
{
- "text": "sumAll([5, 10])
should return 45.",
- "testString": "assert.deepEqual(sumAll([5, 10]), 45, 'sumAll([5, 10])
should return 45.');"
+ "text": "sumAll([5, 10])
应该返回 45。",
+ "testString": "assert.deepEqual(sumAll([5, 10]), 45, 'sumAll([5, 10])
应该返回 45。');"
},
{
- "text": "sumAll([10, 5])
should return 45.",
- "testString": "assert.deepEqual(sumAll([10, 5]), 45, 'sumAll([10, 5])
should return 45.');"
+ "text": "sumAll([10, 5])
应该返回 45。",
+ "testString": "assert.deepEqual(sumAll([10, 5]), 45, 'sumAll([10, 5])
应该返回 45。');"
}
],
"MDNlinks": [
@@ -70,73 +70,73 @@
"id": "a5de63ebea8dbee56860f4f2",
"title": "Diff Two Arrays",
"description": [
- "Compare two arrays and return a new array with any items only found in one of the two given arrays, but not both. In other words, return the symmetric difference of the two arrays.",
- "Remember to use Read-Search-Ask if you get stuck. Try to pair program. Write your own code.",
- "NotediffArray([1, 2, 3, 5], [1, 2, 3, 4, 5])
should return an array.",
- "testString": "assert(typeof diffArray([1, 2, 3, 5], [1, 2, 3, 4, 5]) === \"object\", 'diffArray([1, 2, 3, 5], [1, 2, 3, 4, 5])
should return an array.');"
+ "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\"]
should return [\"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\"]
should return [\"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\"]
should return an array with one item.",
- "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\"]
should return an array with one item.');"
+ "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\"]
should return [\"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\"]
should return [\"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\"]
should return an array with two items.",
- "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\"]
should return an array with two items.');"
+ "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\"]
should return []
.",
- "testString": "assert.sameMembers(diffArray([\"andesite\", \"grass\", \"dirt\", \"dead shrub\"], [\"andesite\", \"grass\", \"dirt\", \"dead shrub\"]), [], '[\"andesite\", \"grass\", \"dirt\", \"dead shrub\"], [\"andesite\", \"grass\", \"dirt\", \"dead shrub\"]
should return []
.');"
+ "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\"]
should return an empty array.",
- "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\"]
should return an empty array.');"
+ "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]
should return [4]
.",
- "testString": "assert.sameMembers(diffArray([1, 2, 3, 5], [1, 2, 3, 4, 5]), [4], '[1, 2, 3, 5], [1, 2, 3, 4, 5]
should return [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]
should return an array with one item.",
- "testString": "assert(diffArray([1, 2, 3, 5], [1, 2, 3, 4, 5]).length === 1, '[1, 2, 3, 5], [1, 2, 3, 4, 5]
should return an array with one item.');"
+ "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]
should return [\"piglet\", 4]
.",
- "testString": "assert.sameMembers(diffArray([1, \"calf\", 3, \"piglet\"], [1, \"calf\", 3, 4]), [\"piglet\", 4], '[1, \"calf\", 3, \"piglet\"], [1, \"calf\", 3, 4]
should return [\"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]
should return an array with two items.",
- "testString": "assert(diffArray([1, \"calf\", 3, \"piglet\"], [1, \"calf\", 3, 4]).length === 2, '[1, \"calf\", 3, \"piglet\"], [1, \"calf\", 3, 4]
should return an array with two items.');"
+ "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\"]
should return [\"snuffleupagus\", \"cookie monster\", \"elmo\"]
.",
- "testString": "assert.sameMembers(diffArray([], [\"snuffleupagus\", \"cookie monster\", \"elmo\"]), [\"snuffleupagus\", \"cookie monster\", \"elmo\"], '[], [\"snuffleupagus\", \"cookie monster\", \"elmo\"]
should return [\"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\"]
should return an array with three items.",
- "testString": "assert(diffArray([], [\"snuffleupagus\", \"cookie monster\", \"elmo\"]).length === 3, '[], [\"snuffleupagus\", \"cookie monster\", \"elmo\"]
should return an array with three items.');"
+ "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\"]
should return [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\"]
should return [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\"]
should return an array with six items.",
- "testString": "assert(diffArray([1, \"calf\", 3, \"piglet\"], [7, \"filly\"]).length === 6, '[1, \"calf\", 3, \"piglet\"], [7, \"filly\"]
should return an array with six items.');"
+ "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": [
@@ -156,7 +156,7 @@
"contents": [
"function diffArray(arr1, arr2) {",
" var newArr = [];",
- " // Same, same; but different.",
+ " // 这是一个党异伐同的过程",
" return newArr;",
"}",
"",
@@ -171,34 +171,34 @@
"id": "a39963a4c10bc8b4d4f06d7e",
"title": "Seek and Destroy",
"description": [
- "You will be provided with an initial array (the first argument in the destroyer function), followed by one or more arguments. Remove all elements from the initial array that are of the same value as these arguments.",
- "Notearguments
object.",
- "Remember to use Read-Search-Ask if you get stuck. Write your own code."
+ "在这道题目中,我们要写一个叫 destroyer
的函数。传给它的第一个参数是数组,我们称他为初始数组。后续的参数数量是不确定的,可能有一个或多个。你需要做的是,从初始数组中移除所有与后续参数相等的元素,并返回移除元素后的数组。",
+ "注意:arguments
对象,也可以使用 ...
,即“剩余参数”(Rest Parameters)语法。",
+ "如果你遇到了问题,请点击 帮助。"
],
"tests": [
{
- "text": "destroyer([1, 2, 3, 1, 2, 3], 2, 3)
should return [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)
should return [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)
should return [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)
should return [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)
should return [1]
.",
- "testString": "assert.deepEqual(destroyer([3, 5, 1, 2, 2], 2, 3, 5), [1], 'destroyer([3, 5, 1, 2, 2], 2, 3, 5)
should return [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)
should return []
.",
- "testString": "assert.deepEqual(destroyer([2, 3, 2, 3], 2, 3), [], 'destroyer([2, 3, 2, 3], 2, 3)
should return []
.');"
+ "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)
should return [\"hamburger\"]
.",
- "testString": "assert.deepEqual(destroyer([\"tree\", \"hamburger\", 53], \"tree\", 53), [\"hamburger\"], 'destroyer([\"tree\", \"hamburger\", 53], \"tree\", 53)
should return [\"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\")
should return [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\")
should return [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,
@@ -217,7 +217,7 @@
"name": "index",
"contents": [
"function destroyer(arr) {",
- " // Remove all the values",
+ " // 删掉那些值",
" return arr;",
"}",
"",
@@ -232,37 +232,37 @@
"id": "a8e512fbe388ac2f9198f0fa",
"title": "Wherefore art thou",
"description": [
- "Make a function that looks through an array of objects (first argument) and returns an array of all objects that have matching name and value pairs (second argument). Each name and value pair of the source object has to be present in the object from the collection if it is to be included in the returned array.",
- "For example, if the first argument is [{ first: \"Romeo\", last: \"Montague\" }, { first: \"Mercutio\", last: null }, { first: \"Tybalt\", last: \"Capulet\" }]
, and the second argument is { last: \"Capulet\" }
, then you must return the third object from the array (the first argument), because it contains the name and its value, that was passed on as the second argument.",
- "Remember to use Read-Search-Ask if you get stuck. Write your own code."
+ "在这道题目中,我们要写一个函数,它接收两个参数:第一个参数是对象数组,第二个参数是一个对象。我们需要从对象数组中找出与第二个参数相等或包含第二个参数的所有对象,并以对象数组的形式返回。其中,相等的意思是原数组中的对象与第二个参数中对象的所有键值对完全相等;包含的意思是只要第二个参数中对象的所有键存在于原数组对象中,且它们对应的值相同即可。",
+ "比如,如果第一个参数是 [{ 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\" })
should return [{ 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\" })
should return [{ 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 })
should return [{ \"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 })
should return [{ \"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 })
should return [{ \"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 })
should return [{ \"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 })
should return [{ \"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 })
should return [{ \"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 })
should return [{ \"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 })
should return [{ \"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})
should return []
",
- "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})
should return []
');"
+ "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": [
@@ -281,10 +281,10 @@
"function whatIsInAName(collection, source) {",
" // What's in a name?",
" var arr = [];",
- " // Only change code below this line",
+ " // 请把你的代码写在这条注释以下",
" ",
" ",
- " // Only change code above this line",
+ " // 请把你的代码写在这条注释以上",
" return arr;",
"}",
"",
@@ -299,32 +299,32 @@
"id": "a103376db3ba46b2d50db289",
"title": "Spinal Tap Case",
"description": [
- "Convert a string to spinal case. Spinal case is all-lowercase-words-joined-by-dashes.",
- "Remember to use Read-Search-Ask if you get stuck. Try to pair program. Write your own code."
+ "在这道题目中,我们需要写一个函数,把一个字符串转换为“短线连接格式”。短线连接格式的意思是,所有字母都是小写,且用 -
连接。比如,对于 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\")
should return \"this-is-spinal-tap\"
.",
- "testString": "assert.deepEqual(spinalCase(\"This Is Spinal Tap\"), \"this-is-spinal-tap\", 'spinalCase(\"This Is Spinal Tap\")
should return \"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\")
should return \"this-is-spinal-tap\"
.",
- "testString": "assert.strictEqual(spinalCase('thisIsSpinalTap'), \"this-is-spinal-tap\", 'spinalCase(\"thisIsSpinalTap\")
should return \"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\")
should return \"the-andy-griffith-show\"
.",
- "testString": "assert.strictEqual(spinalCase(\"The_Andy_Griffith_Show\"), \"the-andy-griffith-show\", 'spinalCase(\"The_Andy_Griffith_Show\")
should return \"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\")
should return \"teletubbies-say-eh-oh\"
.",
- "testString": "assert.strictEqual(spinalCase(\"Teletubbies say Eh-oh\"), \"teletubbies-say-eh-oh\", 'spinalCase(\"Teletubbies say Eh-oh\")
should return \"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\")
should return \"all-the-small-things\"
.",
- "testString": "assert.strictEqual(spinalCase(\"AllThe-small Things\"), \"all-the-small-things\", 'spinalCase(\"AllThe-small Things\")
should return \"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": [
@@ -340,8 +340,7 @@
"name": "index",
"contents": [
"function spinalCase(str) {",
- " // \"It's such a fine line between stupid, and clever.\"",
- " // --David St. Hubbins",
+ "",
" return str;",
"}",
"",
@@ -356,43 +355,43 @@
"id": "aa7697ea2477d1316795783b",
"title": "Pig Latin",
"description": [
- "Translate the provided string to pig latin.",
- "Pig Latin takes the first consonant (or consonant cluster) of an English word, moves it to the end of the word and suffixes an \"ay\".",
- "If a word begins with a vowel you just add \"way\" to the end.",
- "Input strings are guaranteed to be English words in all lowercase.",
- "Remember to use Read-Search-Ask if you get stuck. Try to pair program. Write your own code."
+ "在这道题目中,我们需要写一个函数,把传入的字符串翻译成“儿童黑话”。",
+ "儿童黑话的基本转换规则很简单,只需要把一个英文单词的第一个辅音字母或第一组辅音从移到单词的结尾,并在后面加上 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\")
should return \"aliforniacay\".",
- "testString": "assert.deepEqual(translatePigLatin(\"california\"), \"aliforniacay\", 'translatePigLatin(\"california\")
should return \"aliforniacay\".');"
+ "text": "translatePigLatin(\"california\")
应该返回 \"aliforniacay\"。",
+ "testString": "assert.deepEqual(translatePigLatin(\"california\"), \"aliforniacay\", 'translatePigLatin(\"california\")
应该返回 \"aliforniacay\"。');"
},
{
- "text": "translatePigLatin(\"paragraphs\")
should return \"aragraphspay\".",
- "testString": "assert.deepEqual(translatePigLatin(\"paragraphs\"), \"aragraphspay\", 'translatePigLatin(\"paragraphs\")
should return \"aragraphspay\".');"
+ "text": "translatePigLatin(\"paragraphs\")
应该返回 \"aragraphspay\"。",
+ "testString": "assert.deepEqual(translatePigLatin(\"paragraphs\"), \"aragraphspay\", 'translatePigLatin(\"paragraphs\")
应该返回 \"aragraphspay\"。');"
},
{
- "text": "translatePigLatin(\"glove\")
should return \"oveglay\".",
- "testString": "assert.deepEqual(translatePigLatin(\"glove\"), \"oveglay\", 'translatePigLatin(\"glove\")
should return \"oveglay\".');"
+ "text": "translatePigLatin(\"glove\")
应该返回 \"oveglay\"。",
+ "testString": "assert.deepEqual(translatePigLatin(\"glove\"), \"oveglay\", 'translatePigLatin(\"glove\")
应该返回 \"oveglay\"。');"
},
{
- "text": "translatePigLatin(\"algorithm\")
should return \"algorithmway\".",
- "testString": "assert.deepEqual(translatePigLatin(\"algorithm\"), \"algorithmway\", 'translatePigLatin(\"algorithm\")
should return \"algorithmway\".');"
+ "text": "translatePigLatin(\"algorithm\")
应该返回 \"algorithmway\"。",
+ "testString": "assert.deepEqual(translatePigLatin(\"algorithm\"), \"algorithmway\", 'translatePigLatin(\"algorithm\")
应该返回 \"algorithmway\"。');"
},
{
- "text": "translatePigLatin(\"eight\")
should return \"eightway\".",
- "testString": "assert.deepEqual(translatePigLatin(\"eight\"), \"eightway\", 'translatePigLatin(\"eight\")
should return \"eightway\".');"
+ "text": "translatePigLatin(\"eight\")
应该返回 \"eightway\"。",
+ "testString": "assert.deepEqual(translatePigLatin(\"eight\"), \"eightway\", 'translatePigLatin(\"eight\")
应该返回 \"eightway\"。');"
},
{
- "text": "Should handle words where the first vowel comes in the end of the word.",
- "testString": "assert.deepEqual(translatePigLatin(\"schwartz\"), \"artzschway\", 'Should handle words where the first vowel comes in the end of the word.');"
+ "text": "你的代码应当能够处理第一个元音字母在单词结尾的情况。比如 translatePigLatin(\"she\")
应该返回 \"eshay\"。",
+ "testString": "assert.deepEqual(translatePigLatin(\"she\"), \"eshay\", '你的代码应当能够处理第一个元音字母在单词结尾的情况。比如 translatePigLatin(\"she\")
应该返回 \"eshay\"。');"
},
{
- "text": "Should handle words without vowels.",
- "testString": "assert.deepEqual(translatePigLatin(\"rhythm\"), \"rhythmay\", 'Should handle words without vowels.');"
+ "text": "你的代码应当能够处理单词中不含元音字母的情况。比如 translatePigLatin(\"rhythm\")
应该返回 \"rhythmay\"。",
+ "testString": "assert.deepEqual(translatePigLatin(\"rhythm\"), \"rhythmay\", '你的代码应当能够处理单词中不含元音字母的情况。比如 translatePigLatin(\"rhythm\")
应该返回 \"rhythmay\"。');"
}
],
"MDNlinks": [
@@ -425,36 +424,36 @@
"id": "a0b5010f579e69b815e7c5d6",
"title": "Search and Replace",
"description": [
- "Perform a search and replace on the sentence using the arguments provided and return the new sentence.",
- "First argument is the sentence to perform the search and replace on.",
- "Second argument is the word that you will be replacing (before).",
- "Third argument is what you will be replacing the second argument with (after).",
- "NotemyReplace(\"Let us go to the store\", \"store\", \"mall\")
should return \"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\")
should return \"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\")
should return \"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\")
should return \"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\")
should return \"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\")
should return \"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\")
should return \"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\")
should return \"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\")
should return \"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\")
should return \"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": [
@@ -485,28 +484,27 @@
"id": "afd15382cdfb22c9efe8b7de",
"title": "DNA Pairing",
"description": [
- "The DNA strand is missing the pairing element. Take each character, get its pair, and return the results as a 2d array.",
- "Base pairs are a pair of AT and CG. Match the missing element to the provided character.",
- "Return the provided character as the first element in each array.",
- "For example, for the input GCG, return [[\"G\", \"C\"], [\"C\",\"G\"],[\"G\", \"C\"]]",
- "The character and its pair are paired up in an array, and all the arrays are grouped into one encapsulating array.",
- "Remember to use Read-Search-Ask if you get stuck. Try to pair program. Write your own code."
+ "在这道题目中,我们需要写一个函数,为 DNA 中的碱基配对。这个函数只接收一个表示碱基的字符串为参数,最后返回完成配对的二维数组。",
+ "碱基对 由一对碱基组成。碱基有四种,分别为 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\")
should return [[\"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\")
should return [[\"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\")
should return [[\"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\")
should return [[\"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\")
should return [[\"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\")
should return [[\"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": [
@@ -536,33 +534,33 @@
"id": "af7588ade1100bde429baf20",
"title": "Missing letters",
"description": [
- "Find the missing letter in the passed letter range and return it.",
- "If all letters are present in the range, return undefined.",
- "Remember to use Read-Search-Ask if you get stuck. Try to pair program. Write your own code."
+ "在这道题目中,我们需要写一个函数,找到传入的字符串里缺失的字母并返回它。",
+ "判断缺失的依据是字母顺序,比如 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\")
should return \"d\".",
- "testString": "assert.deepEqual(fearNotLetter('abce'), 'd', 'fearNotLetter(\"abce\")
should return \"d\".');"
+ "text": "fearNotLetter(\"abce\")
应该返回 \"d\"。",
+ "testString": "assert.deepEqual(fearNotLetter('abce'), 'd', 'fearNotLetter(\"abce\")
应该返回 \"d\"。');"
},
{
- "text": "fearNotLetter(\"abcdefghjklmno\")
should return \"i\".",
- "testString": "assert.deepEqual(fearNotLetter('abcdefghjklmno'), 'i', 'fearNotLetter(\"abcdefghjklmno\")
should return \"i\".');"
+ "text": "fearNotLetter(\"abcdefghjklmno\")
应该返回 \"i\"。",
+ "testString": "assert.deepEqual(fearNotLetter('abcdefghjklmno'), 'i', 'fearNotLetter(\"abcdefghjklmno\")
应该返回 \"i\"。');"
},
{
- "text": "fearNotLetter(\"stvwx\")
should return \"u\".",
- "testString": "assert.deepEqual(fearNotLetter('stvwx'), 'u', 'fearNotLetter(\"stvwx\")
should return \"u\".');"
+ "text": "fearNotLetter(\"stvwx\")
应该返回 \"u\"。",
+ "testString": "assert.deepEqual(fearNotLetter('stvwx'), 'u', 'fearNotLetter(\"stvwx\")
应该返回 \"u\"。');"
},
{
- "text": "fearNotLetter(\"bcdf\")
should return \"e\".",
- "testString": "assert.deepEqual(fearNotLetter('bcdf'), 'e', 'fearNotLetter(\"bcdf\")
should return \"e\".');"
+ "text": "fearNotLetter(\"bcdf\")
应该返回 \"e\"。",
+ "testString": "assert.deepEqual(fearNotLetter('bcdf'), 'e', 'fearNotLetter(\"bcdf\")
应该返回 \"e\"。');"
},
{
- "text": "fearNotLetter(\"abcdefghijklmnopqrstuvwxyz\")
should return undefined.",
- "testString": "assert.isUndefined(fearNotLetter('abcdefghijklmnopqrstuvwxyz'), 'fearNotLetter(\"abcdefghijklmnopqrstuvwxyz\")
should return undefined.');"
+ "text": "fearNotLetter(\"abcdefghijklmnopqrstuvwxyz\")
应该返回 undefined
。",
+ "testString": "assert.isUndefined(fearNotLetter('abcdefghijklmnopqrstuvwxyz'), 'fearNotLetter(\"abcdefghijklmnopqrstuvwxyz\")
应该返回 undefined
。');"
}
],
"MDNlinks": [
@@ -592,31 +590,30 @@
"id": "a105e963526e7de52b219be9",
"title": "Sorted Union",
"description": [
- "Write a function that takes two or more arrays and returns a new array of unique values in the order of the original provided arrays.",
- "In other words, all values present from all arrays should be included in their original order, but with no duplicates in the final array.",
- "The unique numbers should be sorted by their original order, but the final array should not be sorted in numerical order.",
- "Check the assertion tests for examples.",
- "Remember to use Read-Search-Ask if you get stuck. Try to pair program. Write your own code."
+ "在这道题目中,我们需要写一个函数,它接收两个或多个数组为参数。我们需要对这些数组中所有元素进行去除重复元素的处理,并以数组的形式返回去重结果。",
+ "需要注意的是,结果数组中的元素顺序必须与其传入的顺序保持一致。",
+ "如有疑问,请先浏览下方的测试用例。",
+ "如果你遇到了问题,请点击 帮助。"
],
"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])
should return [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])
should return [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]])
should return [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]])
should return [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])
should return [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])
should return [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])
should return [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])
should return [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": [
@@ -646,40 +643,40 @@
"id": "a6b0bb188d873cb2c8729495",
"title": "Convert HTML Entities",
"description": [
- "Convert the characters &
, <
, >
, \"
(double quote), and '
(apostrophe), in a string to their corresponding HTML entities.",
- "Remember to use Read-Search-Ask if you get stuck. Try to pair program. Write your own code."
+ "在这道题目中,我们需要写一个转换 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\")
should return Dolce & Gabbana
.",
- "testString": "assert.match(convertHTML(\"Dolce & Gabbana\"), /Dolce & Gabbana/, 'convertHTML(\"Dolce & Gabbana\")
should return 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\")
should return Hamburgers < Pizza < Tacos
.",
- "testString": "assert.match(convertHTML(\"Hamburgers < Pizza < Tacos\"), /Hamburgers < Pizza < Tacos/, 'convertHTML(\"Hamburgers < Pizza < Tacos\")
should return 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\")
should return Sixty > twelve
.",
- "testString": "assert.match(convertHTML(\"Sixty > twelve\"), /Sixty > twelve/, 'convertHTML(\"Sixty > twelve\")
should return 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\"')
should return Stuff in "quotation marks"
.",
- "testString": "assert.match(convertHTML('Stuff in \"quotation marks\"'), /Stuff in "quotation marks"/, 'convertHTML('Stuff in \"quotation marks\"')
should return 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\")
should return Schindler's List
.",
- "testString": "assert.match(convertHTML(\"Schindler's List\"), /Schindler's List/, 'convertHTML(\"Schindler's List\")
should return 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(\"<>\")
should return <>
.",
- "testString": "assert.match(convertHTML('<>'), /<>/, 'convertHTML(\"<>\")
should return <>
.');"
+ "text": "convertHTML(\"<>\")
应该返回 <>
。",
+ "testString": "assert.match(convertHTML('<>'), /<>/, 'convertHTML(\"<>\")
应该返回 <>
。');"
},
{
- "text": "convertHTML(\"abc\")
should return abc
.",
- "testString": "assert.strictEqual(convertHTML('abc'), 'abc', 'convertHTML(\"abc\")
should return abc
.');"
+ "text": "convertHTML(\"abc\")
应该返回 abc
。",
+ "testString": "assert.strictEqual(convertHTML('abc'), 'abc', 'convertHTML(\"abc\")
应该返回 abc
。');"
}
],
"MDNlinks": [
@@ -1309,4 +1306,4 @@
}
}
]
-}
\ No newline at end of file
+}
From 0b9612d03faa6c43606abb307fac4de9d45e8771 Mon Sep 17 00:00:00 2001
From: Xing Liu Math.min()
来获取两数中较小的数。`
+ :slightly_frowning_face: `使用Math。min()
来获取两数中较小的数。`
+
+ ` 标签,无论全半角,任何情况都不添加空格。
+
+ 示例
+
+ :smiley: `使用mongoose.connect
命令来连接数据库。`
+
+
+
+## 翻译原则
+1. 追求意译,不要逐字逐句翻译。可以根据上下文对内容进行必要的补充。
+
+ 示例(有关测试结果的提示信息)
+ 原文:`You can return the array with its elements in any order.`
+
+ :slightly_frowning_face: `你可以返回一个数组,这个数组中的元素顺序无所谓`
+ :slightly_frowning_face: `你可以返回一个元素有任意顺序的数组`
+ :smiley: `返回数组中的元素顺序不会影响测试结果`
+
+
+
+ 示例
+ 原文:`JavaScript is important, well, you know.`
+
+ :slightly_frowning_face: `JavaScript 很重要,那么,你知道的。`
+ :smiley: `你知道的,JavaScript 很重要。`
+ :smiley: `JavaScript 很重要,你懂的。`
+
+
+
+2. 尽可能地采用书面语。
+
+ 示例
+ 原文:`Learning JavaScript is fun!`
+
+ :slightly_frowning_face: `学 JavaScript 真的太好玩儿了!`
+ :smiley: `学 JavaScript 很有趣!`
+
+
+
+3. 如需保留原文中的英文,请核实拼写是否与官网或 Wikipedia 一致。如 `JavaScript`、`jQuery`、`React`、`MongoDB` 等。
+
+## 中英有别
+1. 英文与中文的句号用法不同。在翻译的时候,有时我们需要把多个句子合并成一句。
+
+ 示例
+ 原文:`JavaScript is a high-level, interpreted programming language. It is a language which is also characterized as dynamic and weakly typed.`
+
+ :slightly_frowning_face: `JavaScript 是一种高级、解释型的编程语言。它有动态和弱类型的特点。`
+ :smiley: `JavaScript 是一种动态、弱类型、解释型的高级编程语言。`
+
+
+
+2. 英语中的 `a` 和 `an` 有时候不表示数量,而是泛指。此时不应翻译成“一个”。
+
+ 示例
+ 原文:`Use CSS to position an element in a flexible way.`
+
+ :slightly_frowning_face: `以一种灵活的方式使用 CSS 去布局一个元素。`
+ :smiley: `灵活地使用 CSS 布局元素。`
+
+
+
+3. 英语中习惯使用被动语态,中文则习惯使用主动语态。
+
+ 示例
+ 原文:`The direction that child items are arranged is called the main axis.`
+
+ :slightly_frowning_face: `子元素排列的方向被称为主轴。`
+ :smiley: `子元素排列的方向叫做主轴。`
+
+
+
From fdc975873568399b586daceb22fc6a36e50e5ea5 Mon Sep 17 00:00:00 2001
From: Willard Wong
Date: Sat, 28 Jul 2018 16:43:43 +0800
Subject: [PATCH 17/26] Translate managing-packages-with-npm (#1)
* translation 2/10
* translation 4/10
* translate assert & revise
* translation 2/10
* revise
* fix typo
* translation 2/10
* fix typo
* revise
* translate the document
* fix typo
* translate the title
* remove upcoming
---
.../managing-packages-with-npm.json | 200 +++++++++---------
.../managing-packages-with-npm.md | 15 +-
2 files changed, 107 insertions(+), 108 deletions(-)
diff --git a/05-apis-and-microservices/managing-packages-with-npm.json b/05-apis-and-microservices/managing-packages-with-npm.json
index 05d6f0f..6b6e589 100644
--- a/05-apis-and-microservices/managing-packages-with-npm.json
+++ b/05-apis-and-microservices/managing-packages-with-npm.json
@@ -8,21 +8,21 @@
"id": "587d7fb3367417b2b2512bfb",
"title": "How to Use package.json, the Core of Any Node.js Project or npm Package",
"description": [
- "The file package.json is the center of any Node.js project or npm package. It stores information about your project just like the -section in a HTML document describes the content of a webpage. The package.json consists of a single JSON-object where information is stored in \"key\": value-pairs. There are only two required fields in a minimal package.json - name and version - but it’s a good practice to provide additional information about your project that could be useful to future users or maintainers.",
- "The author-field",
- "If you go to the Glitch project that you set up previously and look at on the left side of your screen, you’ll find the file tree where you can see an overview of the various files in your project. Under the file tree’s back-end section, you’ll find package.json - the file that we’ll be improving in the next couple of challenges.",
- "One of the most common pieces of information in this file is the author-field that specifies who’s the creator of a project. It can either be a string or an object with contact details. The object is recommended for bigger projects but in our case, a simple string like the following example will do.",
+ "package.json 是任何 Node.js 项目或 npm 包的中心。它存储项目的相关信息,就像 HTML 文档中的 区域是用来描述网页的通用信息(元信息)一样。package.json 由单个 JSON 对象组成,它以键值对的形式存储项目的信息。一个最小的 package.json 文件至少包含两个必须字段:name 和 version——但是提供有关项目的附加信息是一个更好的做法,在以后它可能对你的用户或者维护者有所帮助。",
+ "author 字段",
+ "如果你转到之前设置的 Glitch 项目并查看屏幕左侧,你会看到一个文件树,你可以在其中查看项目中各种文件的概述。在文件树的末尾部分,你会看到 package.json——我们将在接下来的几个挑战中改进这个文件。",
+ "这个文件中最常见的信息之一是 author 字段,它指定了谁是项目的创建者。它可以是字符串,也可以是带有联系人详细信息的对象。对于较大的项目,建议使用对象,但是在我们的例子中,一个简单的字符串就可以了,比如下面的例子。",
"\"author\": \"Jane Doe\",
",
- "Instructions",
- "Add your name to the author-field in the package.json of your Glitch project.",
- "Remember that you’re writing JSON.",
- "All field-names must use double-quotes (\"), e.g. \"author\"",
- "All fields must be separated with a comma (,)"
+ "说明",
+ "将你的名字添加到 Glitch 项目中,package.json 的 author 字段。",
+ "请记住,你正在编写 JSON 文件。",
+ "所有的字段名必须使用双引号(\")包裹, 比如:\"author\"",
+ "所有字段必须用逗号(,)分隔"
],
"tests": [
{
- "text": "package.json should have a valid \"author\" key",
- "testString": "getUserInput => $.get(getUserInput('url') + '/_api/package.json').then(data => { var packJson = JSON.parse(data); assert(packJson.author, '\"author\" is missing'); }, xhr => { throw new Error(xhr.responseText); })"
+ "text": "package.json 应该有一个有效的 \"author\" 键",
+ "testString": "getUserInput => $.get(getUserInput('url') + '/_api/package.json').then(data => { var packJson = JSON.parse(data); assert(packJson.author, '缺少 \"author\"'); }, xhr => { throw new Error(xhr.responseText); })"
}
],
"solutions": [],
@@ -33,18 +33,18 @@
"id": "587d7fb3367417b2b2512bfc",
"title": "Add a Description to Your package.json",
"description": [
- "The next part of a good package.json is the description-field, where a short but informative description about your project belongs.",
- "If you some day plan to publishing a package to npm, remember that this is the string that should sell your idea to the user when they decide whether to install your package or not. However, that’s not the only use case for the description: Since it’s a great way to summarize what a project does, it’s just as important for your normal Node.js-projects to help other developers, future maintainers or even your future self understand the project quickly.",
- "Regardless of what you plan for your project, a description is definitely recommended. Let’s add something similar to this:",
+ "一个好的 package.json 文件的下一部分就是 description 字段, 通过简洁的文字来描述你的项目。",
+ "如果你计划将来把这个包发布到 npm, 请注意 description 字段的作用是告知用户这个包的用途,这样用户就可以决定是否要安装你发布的包。然而,这并不是描述信息的唯一使用场景:它也是一种很好的总结项目的方式,对于一个普通的 Node.js 项目来说,它可以帮助其它开发者、未来的维护者以及你自己快速地了解项目,这同样非常重要。",
+ "无论你如何计划项目,都建议你使用描述信息。我们来添加类似这样的信息:",
"\"description\": \"A project that does something awesome\",
",
- "Instructions",
- "Add a description to the package.json in your Glitch project.",
- "Remember to use double-quotes for field-names (\") and commas (,) to separate fields."
+ "说明",
+ "在 Glitch 项目的 package.json 中添加描述。",
+ "请记住使用 (\")包裹字段名并且使用(,)分隔字段"
],
"tests": [
{
- "text": "package.json should have a valid \"description\" key",
- "testString": "getUserInput => $.get(getUserInput('url') + '/_api/package.json').then(data => { var packJson = JSON.parse(data); assert(packJson.description, '\"description\" is missing'); }, xhr => { throw new Error(xhr.responseText); })"
+ "text": "package.json 应该有一个有效的 \"description\" 键",
+ "testString": "getUserInput => $.get(getUserInput('url') + '/_api/package.json').then(data => { var packJson = JSON.parse(data); assert(packJson.description, '缺少 \"description\"'); }, xhr => { throw new Error(xhr.responseText); })"
}
],
"solutions": [],
@@ -55,26 +55,26 @@
"id": "587d7fb4367417b2b2512bfd",
"title": "Add Keywords to Your package.json",
"description": [
- "The keywords-field is where you can describe your project using related keywords.",
- "Example",
+ "你可以在 keywords 字段中使用相关的关键字描述项目。",
+ "例子",
"\"keywords\": [ \"descriptive\", \"related\", \"words\" ],
",
- "As you can see, this field is structured as an array of double-quoted strings.",
- "Instructions",
- "Add an array of suitable strings to the keywords-field in the package.json of your Glitch project.",
- "One of the keywords should be freecodecamp."
+ "正如你所见,这个字段的结构是一个由双引号字符串组成的数组。",
+ "说明",
+ "在 Glitch 项目的 package.json 中,给 keywords 添加适当的字符串数组。",
+ "关键词之一应该是 freecodecamp。"
],
"tests": [
{
- "text": "package.json should have a valid \"keywords\" key",
- "testString": "getUserInput => $.get(getUserInput('url') + '/_api/package.json').then(data => { var packJson = JSON.parse(data); assert(packJson.keywords, '\"keywords\" is missing'); }, xhr => { throw new Error(xhr.responseText); })"
+ "text": "package.json 应该有一个有效的 \"keywords\" 键",
+ "testString": "getUserInput => $.get(getUserInput('url') + '/_api/package.json').then(data => { var packJson = JSON.parse(data); assert(packJson.keywords, '缺少 \"keywords\"'); }, xhr => { throw new Error(xhr.responseText); })"
},
{
- "text": "\"keywords\" field should be an Array",
- "testString": "getUserInput => $.get(getUserInput('url') + '/_api/package.json').then(data => { var packJson = JSON.parse(data); assert.isArray(packJson.keywords, '\"keywords\" is not an array'); }, xhr => { throw new Error(xhr.responseText); })"
+ "text": "\"keywords\" 应该是一个数组",
+ "testString": "getUserInput => $.get(getUserInput('url') + '/_api/package.json').then(data => { var packJson = JSON.parse(data); assert.isArray(packJson.keywords, '\"keywords\" 不是一个数组'); }, xhr => { throw new Error(xhr.responseText); })"
},
{
- "text": "\"keywords\" should include \"freecodecamp\"",
- "testString": "getUserInput => $.get(getUserInput('url') + '/_api/package.json').then(data => { var packJson = JSON.parse(data); assert.include(packJson.keywords, 'freecodecamp', '\"keywords\" does not include \"freecodecamp\"'); }, xhr => { throw new Error(xhr.responseText); })"
+ "text": "\"keywords\" 中应该包含关键词 \"freecodecamp\"",
+ "testString": "getUserInput => $.get(getUserInput('url') + '/_api/package.json').then(data => { var packJson = JSON.parse(data); assert.include(packJson.keywords, 'freecodecamp', '\"keywords\" 未包含 \"freecodecamp\"'); }, xhr => { throw new Error(xhr.responseText); })"
}
],
"solutions": [],
@@ -85,18 +85,18 @@
"id": "587d7fb4367417b2b2512bfe",
"title": "Add a License to Your package.json",
"description": [
- "The license-field is where you inform users of your project what they are allowed to do with it.",
- "Some common licenses for open source projects include MIT and BSD. http://choosealicense.com is a great resource if you want to learn more about what license could fit your project.",
- "License information is not required. Copyright laws in most countries will give you ownership of what you create by default. However, it’s always a good practice to explicitly state what users can and can’t do.",
- "Example",
+ "license 字段是你告知用户允许他们拿这个项目干什么的地方。",
+ "常见的开源协议是 MIT 和 BSD。如果你想了解更多适合你项目的许可证的信息,那么 http://choosealicense.com 是一个不错的网站。",
+ "许可证信息并不是必须的。大多数国家的版权法会默认让你拥有自己创作的作品的所有权。但是,明确说明用户可以做什么和不能做什么会是一个很好的做法。",
+ "例子",
"\"license\": \"MIT\",
",
- "Instructions",
- "Fill the license-field in the package.json of your Glitch project as you find suitable."
+ "说明",
+ "在 Glitch 项目的 package.json 中填写合适的 license 字段。"
],
"tests": [
{
- "text": "package.json should have a valid \"license\" key",
- "testString": "getUserInput => $.get(getUserInput('url') + '/_api/package.json').then(data => { var packJson = JSON.parse(data); assert(packJson.license, '\"license\" is missing'); }, xhr => { throw new Error(xhr.responseText); })"
+ "text": "package.json 应该有一个有效的 \"license\" 键",
+ "testString": "getUserInput => $.get(getUserInput('url') + '/_api/package.json').then(data => { var packJson = JSON.parse(data); assert(packJson.license, '缺少 \"license\"'); }, xhr => { throw new Error(xhr.responseText); })"
}
],
"solutions": [],
@@ -107,16 +107,16 @@
"id": "587d7fb4367417b2b2512bff",
"title": "Add a Version to Your package.json",
"description": [
- "The version is together with name one of the required fields in a package.json. This field describes the current version of your project.",
- "Example",
+ "在 package.json 中 version 和 name 是所必填的字段之一。version 字段描述了当前项目的版本。",
+ "例子",
"\"version\": \"1.2\",
",
- "Instructions",
- "Add a version to the package.json in your Glitch project."
+ "说明",
+ "在 Glitch 项目中的 package.json 中添加一个版本号。"
],
"tests": [
{
- "text": "package.json should have a valid \"version\" key",
- "testString": "getUserInput => $.get(getUserInput('url') + '/_api/package.json').then(data => { var packJson = JSON.parse(data); assert(packJson.version, '\"version\" is missing'); }, xhr => { throw new Error(xhr.responseText); })"
+ "text": "package.json 应该包含一个有效的 \"version\" 键",
+ "testString": "getUserInput => $.get(getUserInput('url') + '/_api/package.json').then(data => { var packJson = JSON.parse(data); assert(packJson.version, '缺少 \"version\"'); }, xhr => { throw new Error(xhr.responseText); })"
}
],
"solutions": [],
@@ -127,24 +127,24 @@
"id": "587d7fb4367417b2b2512c00",
"title": "Expand Your Project with External Packages from npm",
"description": [
- "One of the biggest reasons to use a package manager is their powerful dependency management. Instead of manually having to make sure that you get all dependencies whenever you set up a project on a new computer, npm automatically installs everything for you. But how can npm know exactly what your project needs? Meet the dependencies-section of your package.json.",
- "In the dependencies-section, packages your project require are stored using the following format:",
+ "使用包管理器的最大原因之一是它们强大的依赖管理特性。在新的计算机上开始一个项目时,不用手动确认你已安装所有的依赖,npm 会自动为你安装它们。但是 npm 如何准确的知道你项目需要哪些依赖呢?我们来看看 package.json 中 dependencies 这一部分。",
+ "在 dependencies 这一部分,你的项目需要按照下面这种格式来存储这些依赖包:",
"\"dependencies\": {
",
" \"package-name\": \"version\",
",
" \"express\": \"4.14.0\"
",
"}
",
- "Instructions",
- "Add version 2.14.0 of the package moment to the dependencies-field of your package.json",
- "Moment is a handy library for working with time and dates."
+ "说明",
+ "在 package.json 的 dependencies 字段中添加一个版本号为 2.14.0 的 moment 包",
+ "Moment 是一个非常方便的库,它用来处理时间和日期。"
],
"tests": [
{
- "text": "\"dependencies\" should include \"moment\"",
- "testString": "getUserInput => $.get(getUserInput('url') + '/_api/package.json').then(data => { var packJson = JSON.parse(data); assert.property(packJson.dependencies, 'moment', '\"dependencies\" does not include \"moment\"'); }, xhr => { throw new Error(xhr.responseText); })"
+ "text": "\"dependencies\" 应该包含 \"moment\"",
+ "testString": "getUserInput => $.get(getUserInput('url') + '/_api/package.json').then(data => { var packJson = JSON.parse(data); assert.property(packJson.dependencies, 'moment', '\"dependencies\" 未包含 \"moment\"'); }, xhr => { throw new Error(xhr.responseText); })"
},
{
- "text": "\"moment\" version should be \"2.14.0\"",
- "testString": "getUserInput => $.get(getUserInput('url') + '/_api/package.json').then(data => { var packJson = JSON.parse(data); assert.match(packJson.dependencies.moment, /^[\\^\\~]?2\\.14\\.0/, 'Wrong version of \"moment\" installed. It should be 2.14.0'); }, xhr => { throw new Error(xhr.responseText); })"
+ "text": "\"moment\" 的版本应该是 \"2.14.0\"",
+ "testString": "getUserInput => $.get(getUserInput('url') + '/_api/package.json').then(data => { var packJson = JSON.parse(data); assert.match(packJson.dependencies.moment, /^[\\^\\~]?2\\.14\\.0/, '安装的 \"moment\" 版本有误。它应该是 2.14.0'); }, xhr => { throw new Error(xhr.responseText); })"
}
],
"solutions": [],
@@ -155,29 +155,29 @@
"id": "587d7fb5367417b2b2512c01",
"title": "Manage npm Dependencies By Understanding Semantic Versioning",
"description": [
- "Versions of the npm packages in the dependencies-section of your package.json follow what’s called Semantic Versioning (SemVer), an industry standard for software versioning aiming to make it easier to manage dependencies. Libraries, frameworks or other tools published on npm should use SemVer in order to clearly communicate what kind of changes that projects who depend on the package can expect if they update.",
- "SemVer doesn’t make sense in projects without public APIs - so unless your project is similar to the examples above, use another versioning format.",
- "So why do you need to understand SemVer?",
- "Knowing SemVer can be useful when you develop software that use external dependencies (which you almost always do). One day, your understanding of these numbers will save you from accidentally introducing breaking changes to your project without understanding why things “that worked yesterday” suddenly doesn’t.",
- "This is how Semantic Versioning works according to the official website:",
- "Given a version number MAJOR.MINOR.PATCH, increment the:",
- "MAJOR version when you make incompatible API changes,",
- "MINOR version when you add functionality in a backwards-compatible manner, and",
- "PATCH version when you make backwards-compatible bug fixes.",
- "This means that PATCHes are bug fixes and MINORs add new features but neither of them break what worked before. Finally, MAJORs add changes that won’t work with earlier versions.",
- "Example",
- "A semantic version number: 1.3.8",
- "Instructions",
- "In the dependencies-section of your package.json, change the version of moment to match MAJOR version 2, MINOR version 10 and PATCH version 2"
+ "在 package.json 中,dependencies 这部分的 npm 包的版本号遵循所谓的语义化版本(SemVer),它是一种软件版本控制的行业标准,旨在使管理依赖项更加容易。在 npm 上发布的库、框架或其它工具都应该使用语义化版本(SemVer),以便让使用该依赖包的用户能够在依赖包需要升级时,提前规划自己的项目需要为之做出的改动。",
+ "在没有公共 API 的项目中,语义化版本(SemVer)没有意义——除非你的项目与上面的例子类似,否则请使用其它的版本控制方式吧。",
+ "为什么你需要了解语义化版本(SemVer)?",
+ "在开发使用外部依赖项的软件(大多数情况都是这样)时,了解语义化版本(SemVer)会很有用。有一天你会明白这些数字的含义,在项目中它可以避免你意外地引入一些非向下兼容的更改,同时也能避免“昨天还能好好的运行,今天就不行了”这种情况发生。",
+ "根据语义化版本(SemVer)官方网站,它是这样规定的:",
+ "版本格式:主版本号.次版本号.修订号
,版本号递增规则如下:",
+ "主版本号:当你做了不向下兼容的公共 API 修改,",
+ "次版本号:当你添加了向下兼容的新功能,",
+ "修订号:当你做了向下兼容的问题修正。",
+ "这意味着修订号是用来修复错误的,次版本号则是添加了新功能,但它们都没有破坏之前的功能。最后,主版本号的变更则是添加了对早期版本不兼容的更改。",
+ "例子",
+ "一个语义化的版本号:1.3.8",
+ "说明",
+ "在 package.json 中,修改 dependencies 里的 moment 的版本号,让它的主版本是 2,次版本号是 10,修订号是 2。"
],
"tests": [
{
- "text": "\"dependencies\" should include \"moment\"",
- "testString": "getUserInput => $.get(getUserInput('url') + '/_api/package.json').then(data => { var packJson = JSON.parse(data); assert.property(packJson.dependencies, 'moment', '\"dependencies\" does not include \"moment\"'); }, xhr => { throw new Error(xhr.responseText); })"
+ "text": "\"dependencies\" 应该包含 \"moment\"",
+ "testString": "getUserInput => $.get(getUserInput('url') + '/_api/package.json').then(data => { var packJson = JSON.parse(data); assert.property(packJson.dependencies, 'moment', '\"dependencies\" 未包含 \"moment\"'); }, xhr => { throw new Error(xhr.responseText); })"
},
{
- "text": "\"moment\" version should be \"2.10.2\"",
- "testString": "getUserInput => $.get(getUserInput('url') + '/_api/package.json').then(data => { var packJson = JSON.parse(data); assert.match(packJson.dependencies.moment, /^[\\^\\~]?2\\.10\\.2/, 'Wrong version of \"moment\". It should be 2.10.2'); }, xhr => { throw new Error(xhr.responseText); })"
+ "text": "\"moment\" 的版本号应该是 \"2.10.2\"",
+ "testString": "getUserInput => $.get(getUserInput('url') + '/_api/package.json').then(data => { var packJson = JSON.parse(data); assert.match(packJson.dependencies.moment, /^[\\^\\~]?2\\.10\\.2/, '\"moment\" 的版本号有误。它应该是 2.10.2'); }, xhr => { throw new Error(xhr.responseText); })"
}
],
"solutions": [],
@@ -188,22 +188,22 @@
"id": "587d7fb5367417b2b2512c02",
"title": "Use the Tilde-Character to Always Use the Latest Patch Version of a Dependency",
"description": [
- "In the last challenge, we told npm to only include a specific version of a package. That’s a useful way to freeze your dependencies if you need to make sure that different parts of your project stay compatible with each other. But in most use cases you don’t want to miss bug fixes, since they often include important security patches and (hopefully) don’t break things in doing so.",
- "To allow a npm dependency to get updated to the latest PATCH-version, you can prefix the dependency’s version with the tilde-character (~). In package.json, our current rule for how npm may upgrade moment is to use a specific version only (2.10.2), but we want to allow the latest 2.10.x-version.",
- "Example",
- "\"some-package-name\": \"~1.3.8\" allows updates to any 1.3.x version.
",
- "Instructions",
- "Use the tilde-character (~) to prefix the version of moment in your dependencies and allow npm to update it to any new PATCH release.",
- "Note that the version numbers themselves not should be changed."
+ "在最后一个挑战中,我们告诉 npm 只包含特定版本的依赖包。如果想让项目各个部分保持相互兼容,锁定依赖包版本是一个有效的办法。但是大多数情况下,我们并不希望错过依赖项的问题修复,因为它们通常包含重要的安全补丁,而且它们理论上也会兼容我们既有的代码。",
+ "为了让 npm 依赖项更新到最新的修订版,你可以在依赖包的版本号前加一个波浪符号(~)。在 package.json 中,我们当前的 moment 依赖包更新规则是:仅使用特定版本(2.10.2),但我们想用它最新的 2.10.x 版本。",
+ "例子",
+ "\"some-package-name\": \"~1.3.8\" 定义这个包允许使用的版本为 1.3.x。
",
+ "说明",
+ "在 dependencies 中,给 moment 的版本号添加波浪符号(~)前缀,允许 npm 将其更新为最新的修订版。",
+ "请注意,原本的版本号不用更改。"
],
"tests": [
{
- "text": "\"dependencies\" should include \"moment\"",
- "testString": "getUserInput => $.get(getUserInput('url') + '/_api/package.json').then(data => { var packJson = JSON.parse(data); assert.property(packJson.dependencies, 'moment', '\"dependencies\" does not include \"moment\"'); }, xhr => { throw new Error(xhr.responseText); })"
+ "text": "\"dependencies\" 应该包含 \"moment\"",
+ "testString": "getUserInput => $.get(getUserInput('url') + '/_api/package.json').then(data => { var packJson = JSON.parse(data); assert.property(packJson.dependencies, 'moment', '\"dependencies\" 未包含 \"moment\"'); }, xhr => { throw new Error(xhr.responseText); })"
},
{
- "text": "\"moment\" version should match \"~2.10.2\"",
- "testString": "getUserInput => $.get(getUserInput('url') + '/_api/package.json').then(data => { var packJson = JSON.parse(data); assert.match(packJson.dependencies.moment, /^\\~2\\.10\\.2/, 'Wrong version of \"moment\". It should be ~2.10.2'); }, xhr => { throw new Error(xhr.responseText); })"
+ "text": "\"moment\" 的版本号应该是 \"~2.10.2\"",
+ "testString": "getUserInput => $.get(getUserInput('url') + '/_api/package.json').then(data => { var packJson = JSON.parse(data); assert.match(packJson.dependencies.moment, /^\\~2\\.10\\.2/, '\"moment\" 版本号有误,它应该是 ~2.10.2'); }, xhr => { throw new Error(xhr.responseText); })"
}
],
"solutions": [],
@@ -214,22 +214,22 @@
"id": "587d7fb5367417b2b2512c03",
"title": "Use the Caret-Character to Use the Latest Minor Version of a Dependency",
"description": [
- "Similar to how the tilde (~) we learned about in the last challenge allow npm to install the latest PATCH for a dependency, the caret (^) allows npm to install future updates as well. The difference is that the caret will allow both MINOR updates and PATCHes.",
- "At the moment, your current version of moment should be ~2.10.2 which allows npm to install to the latest 2.10.x-version. If we instead were to use the caret (^) as our version prefix, npm would instead be allowed to update to any 2.x.x-version.",
- "Example",
- "\"some-package-name\": \"^1.3.8\" allows updates to any 1.x.x version.
",
- "Instructions",
- "Use the caret-character (^) to prefix the version of moment in your dependencies and allow npm to update it to any new MINOR release.",
- "Note that the version numbers themselves not should be changed."
+ "和上一个挑战中我们学到的波浪符号(~)来安装最新的修订版依赖一样,使用插入符号(^)允许 npm 来安装功能更新。它们的不同之处在于:插入符号(^)允许次版本和修订版更新。",
+ "此刻,你项目中的 moment 依赖包的版本应该是 ~2.10.2,这意味着 npm 可以安装 2.10.x 版的 moment,如果使用插入符号(^)来替换版本号的前缀,那么 npm 可以安装的版本则是 2.x.x。",
+ "例子",
+ "\"some-package-name\": \"^1.3.8\" 定义这个包允许使用的版本为 1.x.x。
",
+ "说明",
+ "使用插入符号(^)为依赖项中的 moment 版本添加前缀,允许 npm 更新依赖包到任意向下兼容的新功能版。",
+ "请注意,原本的版本号不用更改。"
],
"tests": [
{
"text": "\"dependencies\" should include \"moment\"",
- "testString": "getUserInput => $.get(getUserInput('url') + '/_api/package.json').then(data => { var packJson = JSON.parse(data); assert.property(packJson.dependencies, 'moment', '\"dependencies\" does not include \"moment\"'); }, xhr => { throw new Error(xhr.responseText); })"
+ "testString": "getUserInput => $.get(getUserInput('url') + '/_api/package.json').then(data => { var packJson = JSON.parse(data); assert.property(packJson.dependencies, 'moment', '\"dependencies\" 未包含 \"moment\"'); }, xhr => { throw new Error(xhr.responseText); })"
},
{
"text": "\"moment\" version should match \"^2.x.x\"",
- "testString": "getUserInput => $.get(getUserInput('url') + '/_api/package.json').then(data => { var packJson = JSON.parse(data); assert.match(packJson.dependencies.moment, /^\\^2\\./, 'Wrong version of \"moment\". It should be ^2.10.2'); }, xhr => { throw new Error(xhr.responseText); })"
+ "testString": "getUserInput => $.get(getUserInput('url') + '/_api/package.json').then(data => { var packJson = JSON.parse(data); assert.match(packJson.dependencies.moment, /^\\^2\\./, '\"moment\" 的版本号有误,它应该是 ^2.10.2'); }, xhr => { throw new Error(xhr.responseText); })"
}
],
"solutions": [],
@@ -240,17 +240,17 @@
"id": "587d7fb5367417b2b2512c04",
"title": "Remove a Package from Your Dependencies",
"description": [
- "Now you’ve tested a few ways you can manage dependencies of your project by using the package.json's dependencies-section. You’ve included external packages by adding them to the file and even told npm what types of versions you want by using special characters as the tilde (~) or the caret (^).",
- "But what if you want to remove an external package that you no longer need? You might already have guessed it - Just remove the corresponding \"key\": value-pair for that from your dependencies.",
- "This same method applies to removing other fields in your package.json as well",
- "Instructions",
- "Remove the package moment from your dependencies.",
- "Make sure you have the right amount of commas after removing it."
+ "在 package.json 中 dependencies 这一部分,目前尝试了一些管理依赖的方式。你已经添加了一些外部的依赖包到项目中,甚至通过一些特殊的字符比如波浪符号(~)或者插入符号(^)来告诉 npm 你想要的版本类型。",
+ "但是,如果想要删除不需要的依赖包,该怎么办呢?你可能已经猜到了——只需要删除 dependencies 中的键值对就行了。",
+ "同样的方法也适用于删除 package.json 中的其它字段",
+ "说明",
+ "删除 moment 依赖包。",
+ "删除依赖包后,确保没有多余的逗号。"
],
"tests": [
{
- "text": "\"dependencies\" should not include \"moment\"",
- "testString": "getUserInput => $.get(getUserInput('url') + '/_api/package.json').then(data => { var packJson = JSON.parse(data); assert.notProperty(packJson.dependencies, 'moment', '\"dependencies\" still includes \"moment\"'); }, xhr => { throw new Error(xhr.responseText); })"
+ "text": "\"dependencies\" 不包含 \"moment\"",
+ "testString": "getUserInput => $.get(getUserInput('url') + '/_api/package.json').then(data => { var packJson = JSON.parse(data); assert.notProperty(packJson.dependencies, 'moment', '\"dependencies\" 中仍然有 \"moment\"'); }, xhr => { throw new Error(xhr.responseText); })"
}
],
"solutions": [],
diff --git a/05-apis-and-microservices/managing-packages-with-npm.md b/05-apis-and-microservices/managing-packages-with-npm.md
index b92c4e1..1a43f5b 100644
--- a/05-apis-and-microservices/managing-packages-with-npm.md
+++ b/05-apis-and-microservices/managing-packages-with-npm.md
@@ -1,14 +1,13 @@
-# Introduction to the Managing Packages with npm Challenges #
+# 挑战简介——使用 npm 管理包 #
-The Node Package Manager (npm) is a command-line tool used by developers to share and control modules (or packages) of JavaScript code written for use with Node.js.
+Node 包管理器(npm)是一种命令行工具,开发人员使用它来分享和管理 Node.js 编写的 JavaScript 模块(包)。
-When starting a new project, npm generates a package.json file. This file lists the package dependencies for your project. Since npm packages are regularly updated, the package.json file allows you to set specific version numbers for each dependency. This ensures that updates to a package don't break your project.
+启动新项目时,npm 会生成一个 package.json 文件。此文件列出了项目的所有依赖。因为依赖包是有规律可循的,package.json 文件允许为每个依赖项设置特定的版本号。以确保这些依赖包更新时不会破坏你的项目。
-npm saves packages in a folder named nodemodules. These packages can be installed in two ways:
+npm 会保存依赖包放入叫 nodemodules 的文件夹内。这些依赖包可以通过两种方式安装:
-globally in a root nodemodules folder, accessible by all projects.
-locally within a project's own node_modules folder, accessible only to that project.
+全局安装的依赖包会放在根目录下叫 nodemodules 的文件夹内,以供所有项目使用
+本地安装的依赖包会放在项目内叫 node_modules 的文件夹内,只可以在当前项目使用
-Most developers prefer to install packages local to each project to create a separation between the dependencies of different projects. Working on these challenges will involve you writing your code on Glitch on our starter project. After completing each challenge you can copy your public Glitch url (to the homepage of your app) into the challenge screen to test it! Optionally you may choose to write your project on another platform but it must be publicly visible for our testing.
-Start this project on Glitch using this link or clone this repository on GitHub! If you use Glitch, remember to save the link to your project somewhere safe!
+为了能隔离不同项目之间的依赖,大多数开发者更喜欢在本地项目内安装依赖包。你需要在 Glitch 里启动这个项目并编写相应的代码来应对这些挑战。完成每个挑战后,你可以将 Glitch 地址公开(到你的应用主页)并复制它们,放到挑战题中进行测试!你可以选择另外的平台编写项目代码,但是必须设置为可公开访问,以便我们进行测试。可以使用这个链接在 Glitch 上开始项目,或者克隆这个 GitHub 仓库链接来开始项目!如果你使用 Glitch,请记住将项目链接保存到安全的地方!
From d07596802513200028100e1d8c19e7e8f4065bb0 Mon Sep 17 00:00:00 2001
From: XERO
Date: Sat, 28 Jul 2018 16:46:16 +0800
Subject: [PATCH 18/26] Translate responsive-web-design-projects (#2)
* part1
* update previous & 2/5 finished
* space fix
* fix part1&part2 spacing
---
.../responsive-web-design-projects.json | 76 +++++++++----------
1 file changed, 38 insertions(+), 38 deletions(-)
diff --git a/01-responsive-web-design/responsive-web-design-projects.json b/01-responsive-web-design/responsive-web-design-projects.json
index da24157..9636a99 100644
--- a/01-responsive-web-design/responsive-web-design-projects.json
+++ b/01-responsive-web-design/responsive-web-design-projects.json
@@ -8,21 +8,21 @@
"id": "bd7158d8c442eddfaeb5bd18",
"title": "Build a Tribute Page",
"description": [
- "Objective: Build a CodePen.io app that is functionally similar to this: https://codepen.io/freeCodeCamp/full/zNqgVx.",
- "Fulfill the below user stories and get all of the tests to pass. Give it your own personal style.",
- "You can use HTML, JavaScript, and CSS to complete this project. Plain CSS is recommended because that is what the lessons have covered so far and you should get some practice with plain CSS. You can use Bootstrap or SASS if you choose. Additional technologies (just for example jQuery, React, Angular, or Vue) are not recommended for this project, and using them is at your own risk. Other projects will give you a chance to work with different technology stacks like React. We will accept and try to fix all issue reports that use the suggested technology stack for this project. Happy coding!",
- "User Story #1: My tribute page should have an element with a corresponding id=\"main\"
, which contains all other elements.",
- "User Story #2: I should see an element with a corresponding id=\"title\"
, which contains a string (i.e. text) that describes the subject of the tribute page (e.g. \"Dr. Norman Borlaug\").",
- "User Story #3: I should see a div
element with a corresponding id=\"img-div\"
.",
- "User Story #4: Within the img-div
element, I should see an img
element with a corresponding id=\"image\"
.",
- "User Story #5: Within the img-div
element, I should see an element with a corresponding id=\"img-caption\"
that contains textual content describing the image shown in img-div
.",
- "User Story #6: I should see an element with a corresponding id=\"tribute-info\"
, which contains textual content describing the subject of the tribute page.",
- "User Story #7: I should see an a
element with a corresponding id=\"tribute-link\"
, which links to an outside site that contains additional information about the subject of the tribute page. HINT: You must give your element an attribute of target
and set it to _blank
in order for your link to open in a new tab (i.e. target=\"_blank\"
).",
- "User Story #8: The img
element should responsively resize, relative to the width of its parent element, without exceeding its original size.",
- "User Story #9: The img
element should be centered within its parent element.",
- "You can build your project by forking this CodePen pen. Or you can use this CDN link to run the tests in any environment you like: https://gitcdn.link/repo/freeCodeCamp/testable-projects-fcc/master/build/bundle.js
.",
- "Once you're done, submit the URL to your working project with all its tests passing.",
- "Remember to use the Read-Search-Ask method if you get stuck."
+ "目标:使用 CodePen.io 搭建一个与这个功能上相似的 app:https://codepen.io/freeCodeCamp/full/zNqgVx。",
+ "在满足以下 用户故事 并能通过所有测试的前提下,你可以根据自己的喜好来美化你的 app。",
+ "你可以使用 HTML、JavaScript 以及 CSS 来完成项目,由于目前我们只学到了 CSS,因此建议你只使用 CSS 完成这个项目,顺便还可以巩固一下之前学到的内容。你也可以使用 Bootstrap 或者是 SASS。在当前的项目中,不推荐使用其他技术如 jQurey、React、Angular 或者是 Vue,因为一旦出现问题,风险自担。但在别的项目中我们仍有机会去使用不同的技术栈比如 React,我们会接受并尽力处理你在使用建议的技术栈过程中遇到的问题,编码愉快!",
+ "用户故事 #1:我的致敬页应有对应 id=\"main\"
的元素, 其中包含其他的所有元素",
+ "用户故事 #2:我应该看到一个具有相应 id=\"title\"
的元素,其中包含描述致敬页主题的字符串 (即文本),如 \"Dr. Norman Borlaug\"。",
+ "用户故事 #3:我应该看到一个带有对应 id=\"img-div\"
的 div
元素。",
+ "用户故事 #4:在 img-div
元素内,我应该看见有对应 id=\"image\"
的 img
元素",
+ "用户故事 #5:在 img-div
元素内,我应该看见一个具有相应 id=\"img-caption\"
的元素,其中包含对 img-div
中图像的描述。",
+ "用户故事 #6:我应该看见具有对应 id=\"tribute-info\"
的元素,其中包含描述致敬页主题的文本内容",
+ "用户故事 #7:我应该看见具有对应 id=\"tribute-link\"
的元素,它链接到一个包含有关致敬页主题额外信息的外部网页,提示: 你必须为元素提供 target
属性,并设置为 _blank
以便在新选项卡中打开连接 (例 target=\"_blank\"
)。",
+ "用户故事 #8:img
元素应相对于其父元素的宽度响应地调整大小,但不超过其原始大小。",
+ "用户故事 #9:img
在其父元素内居中。",
+ "你可以通过 fork 此 CodePen 来构建项目,或者你可以使用此 CDN 链接在你喜欢的任何环境中运行测试:https://gitcdn.link/repo/freeCodeCamp/testable-projects-fcc/master/build/bundle.js
。",
+ "完成项目并通过所有测试后, 输入你的项目在 CodePen 上的链接",
+ "要是卡住的话,记得使用 Read-Search-Ask。"
],
"releasedOn": "January 1, 2016",
"tests": [],
@@ -33,28 +33,28 @@
"id": "587d78af367417b2b2512b03",
"title": "Build a Survey Form",
"description": [
- "Objective: Build a CodePen.io app that is functionally similar to this: https://codepen.io/freeCodeCamp/full/VPaoNP.",
- "Fulfill the below user stories and get all of the tests to pass. Give it your own personal style.",
- "You can use HTML, JavaScript, and CSS to complete this project. Plain CSS is recommended because that is what the lessons have covered so far and you should get some practice with plain CSS. You can use Bootstrap or SASS if you choose. Additional technologies (just for example jQuery, React, Angular, or Vue) are not recommended for this project, and using them is at your own risk. Other projects will give you a chance to work with different technology stacks like React. We will accept and try to fix all issue reports that use the suggested technology stack for this project. Happy coding!",
- "User Story #1: I can see a title with id=\"title\"
in H1 sized text.",
- "User Story #2: I can see a short explanation with id=\"description\"
in P sized text.",
- "User Story #3: I can see a form
with id=\"survey-form\"
.",
- "User Story #4: Inside the form element, I am required to enter my name in a field with id=\"name\"
.",
- "User Story #5: Inside the form element, I am required to enter an email in a field with id=\"email\"
.",
- "User Story #6: If I enter an email that is not formatted correctly, I will see an HTML5 validation error.",
- "User Story #7: Inside the form, I can enter a number in a field with id=\"number\"
.",
- "User Story #8: If I enter non-numbers in the number input, I will see an HTML5 validation error.",
- "User Story #9: If I enter numbers outside the range of the number input, which are defined by the min
and max
attributes, I will see an HTML5 validation error.",
- "User Story #10: For the name, email, and number input fields inside the form I can see corresponding labels that describe the purpose of each field with the following ids: id=\"name-label\"
, id=\"email-label\"
, and id=\"number-label\"
.",
- "User Story #11: For the name, email, and number input fields, I can see placeholder text that gives me a description or instructions for each field.",
- "User Story #12: Inside the form element, I can select an option from a dropdown that has a corresponding id=\"dropdown\"
.",
- "User Story #13: Inside the form element, I can select a field from one or more groups of radio buttons. Each group should be grouped using the name
attribute.",
- "User Story #14: Inside the form element, I can select several fields from a series of checkboxes, each of which must have a value
attribute.",
- "User Story #15: Inside the form element, I am presented with a textarea
at the end for additional comments.",
- "User Story #16: Inside the form element, I am presented with a button with id=\"submit\"
to submit all my inputs.",
- "You can build your project by forking this CodePen pen. Or you can use this CDN link to run the tests in any environment you like: https://gitcdn.link/repo/freeCodeCamp/testable-projects-fcc/master/build/bundle.js
",
- "Once you're done, submit the URL to your working project with all its tests passing.",
- "Remember to use the Read-Search-Ask method if you get stuck."
+ "目标:使用CodePen.iohttps://codepen.io/freeCodeCamp/full/VPaoNP
。",
+ "在满足以下 user stories 并能通过所有测试的前提下,你可以根据自己的喜好来美化你的 app。",
+ "你可以使用 HTML、JavaScript 以及 CSS 来完成项目,由于目前我们只学到了 CSS,因此建议你只使用 CSS 完成这个项目,顺便还可以巩固一下之前学到的内容。你也可以使用 Bootstrap 或者是 SASS。在当前的项目中,不推荐使用其他技术如 jQurey、React、Angular 或者是 Vue,因为一旦出现问题,风险自担。但在别的项目中我们仍有机会去使用不同的技术栈比如 React,我们会接受并尽力处理你在使用建议的技术栈过程中遇到的问题,编码愉快!",
+ "用户故事 #1:我能看见一个 H1 大小 id=\"title\"
的标题。",
+ "用户故事 #1:我能看见一个 P 大小 id=\"description\"
的简述文字。",
+ "用户故事 #3:我能看见一个 id=\"survey-form\"
的 form
。",
+ "用户故事 #4:在 form 元素内, 我需要在 id=\"name\"
的字段中输入我的名字。",
+ "用户故事 #5:在 form 元素内, 我需要在 id=\"email\"
的字段中输入邮箱。",
+ "用户故事 #6:如果我输入了格式不正确的邮箱,我将会看见验证错误信息。",
+ "用户故事 #7:id=\"number\" 的字段中输入数字。",
+ "用户故事 #8:如果我在数字输入框内输入非数字,我将会看见验证错误信息。",
+ "用户故事 #9:如果我输入的数字超出了范围(使用 min
和 max
属性定义),我将会看见验证错误信息。",
+ "用户故事 #10:对于表单中的名称,邮箱和数字输入框应该使用对应 id 为:id=\"name-label\"
, id=\"email-label\"
, 和 id=\"number-label\"
的描述标签",
+ "用户故事 #11:在表单中的名称,邮箱和数字输入框中,我能看到各自的描述文字作为占位符。",
+ "用户故事 #12:在表单元素内,我可以在 id=\"dropdown\"
的下拉列表中选择一个选项。",
+ "用户故事 #13:在表单元素内,我可以从一组或多组单选按钮中选择一个字段。每组使用 name code> 属性进行分组。",
+ "用户故事 #14:在表单元素内,我可以从一系列复选框中选择几个字段,每个复选框都必须具有 value 属性。",
+ "用户故事 #15:在表单元素内,我能看见在最后有个 textarea
用于附加注释。",
+ "用户故事 #16:在表单元素内,我能看见一个 id=\"submit\"
的按钮,用于提交我所有的输入。",
+ "你可以通过 fork 此 this CodePen pen 来构建项目,或者你可以使用此 CDN 链接在你喜欢的任何环境中运行测试:https://gitcdn.link/repo/freeCodeCamp/testable-projects-fcc/master/build/bundle.js
。",
+ "完成项目并通过所有测试后, 输入你的项目在 CodePen 上的链接。",
+ "要是卡住的话,记得使用 Read-Search-Ask。"
],
"releasedOn": "January 15, 2017",
"tests": [],
@@ -150,4 +150,4 @@
"challengeType": 3
}
]
-}
\ No newline at end of file
+}
From a995b32796e39831bb2310ab0ae26e01e11ed2a7 Mon Sep 17 00:00:00 2001
From: Stanley
Date: Sat, 28 Jul 2018 16:48:07 +0800
Subject: [PATCH 19/26] Translate information-security-with-helmet (#4)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* 完成helmet第一小节翻译
* Finish 10%
* Remove IDE generated files
* Update according to comments
---
.../information-security-with-helmetjs.json | 38 +++++++++----------
1 file changed, 19 insertions(+), 19 deletions(-)
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 bfc897b..6eda557 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,12 +8,12 @@
"id": "587d8247367417b2b2512c36",
"title": "Install and Require Helmet",
"description": [
- "As a reminder, this project is being built upon the following starter project on Glitch, or cloned from GitHub.",
- "Helmet helps you secure your Express apps by setting various HTTP headers. Install the package, then require it."
+ "注意,本项目在 这个 Glitch 项目 的基础上进行开发。你也可以从 GitHub 上克隆。",
+ "Helmet 通过配置不同的 HTTP 头部信息来使你的 Express 应用更加安全。安装,并引入 Helmet 这个包。"
],
"tests": [
{
- "text": "\"helmet\" dependency should be in package.json",
+ "text": "package.json 文件应该有 \"helmet\" 这个依赖包",
"testString": "getUserInput => $.get(getUserInput('url') + '/_api/package.json').then(data => { var packJson = JSON.parse(data); assert.property(packJson.dependencies, 'helmet'); }, xhr => { throw new Error(xhr.responseText); })"
}
],
@@ -26,12 +26,12 @@
"id": "587d8247367417b2b2512c37",
"title": "Hide Potentially Dangerous Information Using helmet.hidePoweredBy()",
"description": [
- "As a reminder, this project is being built upon the following starter project on Glitch, or cloned from GitHub.",
- "Hackers can exploit known vulnerabilities in Express/Node if they see that your site is powered by Express. X-Powered-By: Express is sent in every request coming from Express by default. The helmet.hidePoweredBy() middleware will remove the X-Powered-By header. You can also explicitly set the header to something else, to throw people off. e.g. 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": [
{
- "text": "helmet.hidePoweredBy() middleware should be mounted correctly",
+ "text": "helmet.hidePoweredBy() 中间件应该被正确加载",
"testString": "getUserInput => $.get(getUserInput('url') + '/_api/app-info').then(data => { assert.include(data.appStack, 'hidePoweredBy'); assert.notEqual(data.headers['x-powered-by'], 'Express')}, xhr => { throw new Error(xhr.responseText); })"
}
],
@@ -44,17 +44,17 @@
"id": "587d8247367417b2b2512c38",
"title": "Mitigate the Risk of Clickjacking with helmet.frameguard()",
"description": [
- "As a reminder, this project is being built upon the following starter project on Glitch, or cloned from GitHub.",
- "Your page could be put in a or