diff --git a/challenges/02-javascript-algorithms-and-data-structures/functional-programming.json b/challenges/02-javascript-algorithms-and-data-structures/functional-programming.json
index 1644da8c30..890d8f0eb7 100644
--- a/challenges/02-javascript-algorithms-and-data-structures/functional-programming.json
+++ b/challenges/02-javascript-algorithms-and-data-structures/functional-programming.json
@@ -20,12 +20,16 @@
],
"tests": [
{
- "text": "The tea4TeamFCC
variable should hold 40 cups of tea for the team.",
- "testString": "assert(tea4TeamFCC.length === 40, 'The tea4TeamFCC
variable should hold 40 cups of tea for the team.');"
+ "text":
+ "The tea4TeamFCC
variable should hold 40 cups of tea for the team.",
+ "testString":
+ "assert(tea4TeamFCC.length === 40, 'The tea4TeamFCC
variable should hold 40 cups of tea for the team.');"
},
{
- "text": "The tea4TeamFCC
variable should hold cups of green tea.",
- "testString": "assert(tea4TeamFCC[0] === 'greenTea', 'The tea4TeamFCC
variable should hold cups of green tea.');"
+ "text":
+ "The tea4TeamFCC
variable should hold cups of green tea.",
+ "testString":
+ "assert(tea4TeamFCC[0] === 'greenTea', 'The tea4TeamFCC
variable should hold cups of green tea.');"
}
],
"solutions": [],
@@ -90,20 +94,28 @@
],
"tests": [
{
- "text": "The tea4GreenTeamFCC
variable should hold 27 cups of green tea for the team.",
- "testString": "assert(tea4GreenTeamFCC.length === 27, 'The tea4GreenTeamFCC
variable should hold 27 cups of green tea for the team.');"
+ "text":
+ "The tea4GreenTeamFCC
variable should hold 27 cups of green tea for the team.",
+ "testString":
+ "assert(tea4GreenTeamFCC.length === 27, 'The tea4GreenTeamFCC
variable should hold 27 cups of green tea for the team.');"
},
{
- "text": "The tea4GreenTeamFCC
variable should hold cups of green tea.",
- "testString": "assert(tea4GreenTeamFCC[0] === 'greenTea', 'The tea4GreenTeamFCC
variable should hold cups of green tea.');"
+ "text":
+ "The tea4GreenTeamFCC
variable should hold cups of green tea.",
+ "testString":
+ "assert(tea4GreenTeamFCC[0] === 'greenTea', 'The tea4GreenTeamFCC
variable should hold cups of green tea.');"
},
{
- "text": "The tea4BlackTeamFCC
variable should hold 13 cups of black tea.",
- "testString": "assert(tea4BlackTeamFCC.length === 13, 'The tea4BlackTeamFCC
variable should hold 13 cups of black tea.');"
+ "text":
+ "The tea4BlackTeamFCC
variable should hold 13 cups of black tea.",
+ "testString":
+ "assert(tea4BlackTeamFCC.length === 13, 'The tea4BlackTeamFCC
variable should hold 13 cups of black tea.');"
},
{
- "text": "The tea4BlackTeamFCC
variable should hold cups of black tea.",
- "testString": "assert(tea4BlackTeamFCC[0] === 'blackTea', 'The tea4BlackTeamFCC
variable should hold cups of black tea.');"
+ "text":
+ "The tea4BlackTeamFCC
variable should hold cups of black tea.",
+ "testString":
+ "assert(tea4BlackTeamFCC[0] === 'blackTea', 'The tea4BlackTeamFCC
variable should hold cups of black tea.');"
}
],
"solutions": [],
@@ -253,12 +265,16 @@
],
"tests": [
{
- "text": "Your function incrementer
should not change the value of fixedValue
.",
- "testString": "assert(fixedValue === 4, 'Your function incrementer
should not change the value of fixedValue
.');"
+ "text":
+ "Your function incrementer
should not change the value of fixedValue
.",
+ "testString":
+ "assert(fixedValue === 4, 'Your function incrementer
should not change the value of fixedValue
.');"
},
{
- "text": "Your incrementer
function should return a value that is one larger than the fixedValue
value.",
- "testString": "assert(newValue === 5, 'Your incrementer
function should return a value that is one larger than the fixedValue
value.');"
+ "text":
+ "Your incrementer
function should return a value that is one larger than the fixedValue
value.",
+ "testString":
+ "assert(newValue === 5, 'Your incrementer
function should return a value that is one larger than the fixedValue
value.');"
}
],
"solutions": [],
@@ -305,16 +321,22 @@
],
"tests": [
{
- "text": "Your function incrementer
should not change the value of fixedValue
.",
- "testString": "assert(fixedValue === 4, 'Your function incrementer
should not change the value of fixedValue
.');"
+ "text":
+ "Your function incrementer
should not change the value of fixedValue
.",
+ "testString":
+ "assert(fixedValue === 4, 'Your function incrementer
should not change the value of fixedValue
.');"
},
{
- "text": "Your incrementer
function should take a parameter.",
- "testString": "assert(code.match(/function\\s+?incrementer\\s*?\\(.+?\\)/g), 'Your incrementer
function should take a parameter.');"
+ "text":
+ "Your incrementer
function should take a parameter.",
+ "testString":
+ "assert(code.match(/function\\s+?incrementer\\s*?\\(.+?\\)/g), 'Your incrementer
function should take a parameter.');"
},
{
- "text": "Your incrementer
function should return a value that is one larger than the fixedValue
value.",
- "testString": "assert(newValue === 5, 'Your incrementer
function should return a value that is one larger than the fixedValue
value.');"
+ "text":
+ "Your incrementer
function should return a value that is one larger than the fixedValue
value.",
+ "testString":
+ "assert(newValue === 5, 'Your incrementer
function should return a value that is one larger than the fixedValue
value.');"
}
],
"solutions": [],
@@ -358,20 +380,28 @@
],
"tests": [
{
- "text": "bookList
should not change and still equal [\"The Hound of the Baskervilles\", \"On The Electrodynamics of Moving Bodies\", \"Philosophiæ Naturalis Principia Mathematica\", \"Disquisitiones Arithmeticae\"]
.",
- "testString": "assert(JSON.stringify(bookList) === JSON.stringify([\"The Hound of the Baskervilles\", \"On The Electrodynamics of Moving Bodies\", \"Philosophiæ Naturalis Principia Mathematica\", \"Disquisitiones Arithmeticae\"]), 'bookList
should not change and still equal [\"The Hound of the Baskervilles\", \"On The Electrodynamics of Moving Bodies\", \"Philosophiæ Naturalis Principia Mathematica\", \"Disquisitiones Arithmeticae\"]
.');"
+ "text":
+ "bookList
should not change and still equal [\"The Hound of the Baskervilles\", \"On The Electrodynamics of Moving Bodies\", \"Philosophiæ Naturalis Principia Mathematica\", \"Disquisitiones Arithmeticae\"]
.",
+ "testString":
+ "assert(JSON.stringify(bookList) === JSON.stringify([\"The Hound of the Baskervilles\", \"On The Electrodynamics of Moving Bodies\", \"Philosophiæ Naturalis Principia Mathematica\", \"Disquisitiones Arithmeticae\"]), 'bookList
should not change and still equal [\"The Hound of the Baskervilles\", \"On The Electrodynamics of Moving Bodies\", \"Philosophiæ Naturalis Principia Mathematica\", \"Disquisitiones Arithmeticae\"]
.');"
},
{
- "text": "newBookList
should equal [\"The Hound of the Baskervilles\", \"On The Electrodynamics of Moving Bodies\", \"Philosophiæ Naturalis Principia Mathematica\", \"Disquisitiones Arithmeticae\", \"A Brief History of Time\"]
.",
- "testString": "assert(JSON.stringify(newBookList) === JSON.stringify(['The Hound of the Baskervilles', 'On The Electrodynamics of Moving Bodies', 'Philosophiæ Naturalis Principia Mathematica', 'Disquisitiones Arithmeticae', 'A Brief History of Time']), 'newBookList
should equal [\"The Hound of the Baskervilles\", \"On The Electrodynamics of Moving Bodies\", \"Philosophiæ Naturalis Principia Mathematica\", \"Disquisitiones Arithmeticae\", \"A Brief History of Time\"]
.');"
+ "text":
+ "newBookList
should equal [\"The Hound of the Baskervilles\", \"On The Electrodynamics of Moving Bodies\", \"Philosophiæ Naturalis Principia Mathematica\", \"Disquisitiones Arithmeticae\", \"A Brief History of Time\"]
.",
+ "testString":
+ "assert(JSON.stringify(newBookList) === JSON.stringify(['The Hound of the Baskervilles', 'On The Electrodynamics of Moving Bodies', 'Philosophiæ Naturalis Principia Mathematica', 'Disquisitiones Arithmeticae', 'A Brief History of Time']), 'newBookList
should equal [\"The Hound of the Baskervilles\", \"On The Electrodynamics of Moving Bodies\", \"Philosophiæ Naturalis Principia Mathematica\", \"Disquisitiones Arithmeticae\", \"A Brief History of Time\"]
.');"
},
{
- "text": "newerBookList
should equal [\"The Hound of the Baskervilles\", \"Philosophiæ Naturalis Principia Mathematica\", \"Disquisitiones Arithmeticae\"]
.",
- "testString": "assert(JSON.stringify(newerBookList) === JSON.stringify(['The Hound of the Baskervilles', 'Philosophiæ Naturalis Principia Mathematica', 'Disquisitiones Arithmeticae']), 'newerBookList
should equal [\"The Hound of the Baskervilles\", \"Philosophiæ Naturalis Principia Mathematica\", \"Disquisitiones Arithmeticae\"]
.');"
+ "text":
+ "newerBookList
should equal [\"The Hound of the Baskervilles\", \"Philosophiæ Naturalis Principia Mathematica\", \"Disquisitiones Arithmeticae\"]
.",
+ "testString":
+ "assert(JSON.stringify(newerBookList) === JSON.stringify(['The Hound of the Baskervilles', 'Philosophiæ Naturalis Principia Mathematica', 'Disquisitiones Arithmeticae']), 'newerBookList
should equal [\"The Hound of the Baskervilles\", \"Philosophiæ Naturalis Principia Mathematica\", \"Disquisitiones Arithmeticae\"]
.');"
},
{
- "text": "newestBookList
should equal [\"The Hound of the Baskervilles\", \"Philosophiæ Naturalis Principia Mathematica\", \"Disquisitiones Arithmeticae\", \"A Brief History of Time\"]
.",
- "testString": "assert(JSON.stringify(newestBookList) === JSON.stringify(['The Hound of the Baskervilles', 'Philosophiæ Naturalis Principia Mathematica', 'Disquisitiones Arithmeticae', 'A Brief History of Time']), 'newestBookList
should equal [\"The Hound of the Baskervilles\", \"Philosophiæ Naturalis Principia Mathematica\", \"Disquisitiones Arithmeticae\", \"A Brief History of Time\"]
.');"
+ "text":
+ "newestBookList
should equal [\"The Hound of the Baskervilles\", \"Philosophiæ Naturalis Principia Mathematica\", \"Disquisitiones Arithmeticae\", \"A Brief History of Time\"]
.",
+ "testString":
+ "assert(JSON.stringify(newestBookList) === JSON.stringify(['The Hound of the Baskervilles', 'Philosophiæ Naturalis Principia Mathematica', 'Disquisitiones Arithmeticae', 'A Brief History of Time']), 'newestBookList
should equal [\"The Hound of the Baskervilles\", \"Philosophiæ Naturalis Principia Mathematica\", \"Disquisitiones Arithmeticae\", \"A Brief History of Time\"]
.');"
}
],
"solutions": [],
@@ -441,19 +471,24 @@
"tests": [
{
"text": "The watchList
variable should not change.",
- "testString": "assert(watchList[0].Title === \"Inception\" && watchList[4].Director == \"James Cameron\", 'The watchList
variable should not change.');"
+ "testString":
+ "assert(watchList[0].Title === \"Inception\" && watchList[4].Director == \"James Cameron\", 'The watchList
variable should not change.');"
},
{
"text": "Your code should not use a for
loop.",
- "testString": "assert(!code.match(/for\\s*?\\(.+?\\)/g), 'Your code should not use a for
loop.');"
+ "testString":
+ "assert(!code.match(/for\\s*?\\(.+?\\)/g), 'Your code should not use a for
loop.');"
},
{
"text": "Your code should use the map
method.",
- "testString": "assert(code.match(/\\.map/g), 'Your code should use the map
method.');"
+ "testString":
+ "assert(code.match(/\\.map/g), 'Your code should use the map
method.');"
},
{
- "text": "rating
should equal [{\"title\":\"Inception\",\"rating\":\"8.8\"},{\"title\":\"Interstellar\",\"rating\":\"8.6\"},{\"title\":\"The Dark Knight\",\"rating\":\"9.0\"},{\"title\":\"Batman Begins\",\"rating\":\"8.3\"},{\"title\":\"Avatar\",\"rating\":\"7.9\"}]
.",
- "testString": "assert(JSON.stringify(rating) === JSON.stringify([{\"title\":\"Inception\",\"rating\":\"8.8\"},{\"title\":\"Interstellar\",\"rating\":\"8.6\"},{\"title\":\"The Dark Knight\",\"rating\":\"9.0\"},{\"title\":\"Batman Begins\",\"rating\":\"8.3\"},{\"title\":\"Avatar\",\"rating\":\"7.9\"}]), 'rating
should equal [{\"title\":\"Inception\",\"rating\":\"8.8\"},{\"title\":\"Interstellar\",\"rating\":\"8.6\"},{\"title\":\"The Dark Knight\",\"rating\":\"9.0\"},{\"title\":\"Batman Begins\",\"rating\":\"8.3\"},{\"title\":\"Avatar\",\"rating\":\"7.9\"}]
.');"
+ "text":
+ "rating
should equal [{\"title\":\"Inception\",\"rating\":\"8.8\"},{\"title\":\"Interstellar\",\"rating\":\"8.6\"},{\"title\":\"The Dark Knight\",\"rating\":\"9.0\"},{\"title\":\"Batman Begins\",\"rating\":\"8.3\"},{\"title\":\"Avatar\",\"rating\":\"7.9\"}]
.",
+ "testString":
+ "assert(JSON.stringify(rating) === JSON.stringify([{\"title\":\"Inception\",\"rating\":\"8.8\"},{\"title\":\"Interstellar\",\"rating\":\"8.6\"},{\"title\":\"The Dark Knight\",\"rating\":\"9.0\"},{\"title\":\"Batman Begins\",\"rating\":\"8.3\"},{\"title\":\"Avatar\",\"rating\":\"7.9\"}]), 'rating
should equal [{\"title\":\"Inception\",\"rating\":\"8.8\"},{\"title\":\"Interstellar\",\"rating\":\"8.6\"},{\"title\":\"The Dark Knight\",\"rating\":\"9.0\"},{\"title\":\"Batman Begins\",\"rating\":\"8.3\"},{\"title\":\"Avatar\",\"rating\":\"7.9\"}]
.');"
}
],
"solutions": [],
@@ -609,12 +644,15 @@
],
"tests": [
{
- "text": "new_s
should equal [46, 130, 196, 10]
.",
- "testString": "assert(JSON.stringify(new_s) === JSON.stringify([46, 130, 196, 10]), 'new_s
should equal [46, 130, 196, 10]
.');"
+ "text":
+ "new_s
should equal [46, 130, 196, 10]
.",
+ "testString":
+ "assert(JSON.stringify(new_s) === JSON.stringify([46, 130, 196, 10]), 'new_s
should equal [46, 130, 196, 10]
.');"
},
{
"text": "Your code should not use the map
method.",
- "testString": "assert(!code.match(/\\.map/g), 'Your code should not use the map
method.');"
+ "testString":
+ "assert(!code.match(/\\.map/g), 'Your code should not use the map
method.');"
}
],
"solutions": [],
@@ -660,19 +698,24 @@
"tests": [
{
"text": "The watchList
variable should not change.",
- "testString": "assert(watchList[0].Title === \"Inception\" && watchList[4].Director == \"James Cameron\", 'The watchList
variable should not change.');"
+ "testString":
+ "assert(watchList[0].Title === \"Inception\" && watchList[4].Director == \"James Cameron\", 'The watchList
variable should not change.');"
},
{
"text": "Your code should use the filter
method.",
- "testString": "assert(code.match(/\\.filter/g), 'Your code should use the filter
method.');"
+ "testString":
+ "assert(code.match(/\\.filter/g), 'Your code should use the filter
method.');"
},
{
"text": "Your code should not use a for
loop.",
- "testString": "assert(!code.match(/for\\s*?\\(.+?\\)/g), 'Your code should not use a for
loop.');"
+ "testString":
+ "assert(!code.match(/for\\s*?\\(.+?\\)/g), 'Your code should not use a for
loop.');"
},
{
- "text": "filteredList
should equal [{\"title\": \"Inception\",\"rating\": \"8.8\"},{\"title\": \"Interstellar\",\"rating\": \"8.6\"},{\"title\": \"The Dark Knight\",\"rating\": \"9.0\"},{\"title\": \"Batman Begins\",\"rating\": \"8.3\"}]
.",
- "testString": "assert.deepEqual(filteredList, [{\"title\": \"Inception\",\"rating\": \"8.8\"},{\"title\": \"Interstellar\",\"rating\": \"8.6\"},{\"title\": \"The Dark Knight\",\"rating\": \"9.0\"},{\"title\": \"Batman Begins\",\"rating\": \"8.3\"}], 'filteredList
should equal [{\"title\": \"Inception\",\"rating\": \"8.8\"},{\"title\": \"Interstellar\",\"rating\": \"8.6\"},{\"title\": \"The Dark Knight\",\"rating\": \"9.0\"},{\"title\": \"Batman Begins\",\"rating\": \"8.3\"}]
.');"
+ "text":
+ "filteredList
should equal [{\"title\": \"Inception\",\"rating\": \"8.8\"},{\"title\": \"Interstellar\",\"rating\": \"8.6\"},{\"title\": \"The Dark Knight\",\"rating\": \"9.0\"},{\"title\": \"Batman Begins\",\"rating\": \"8.3\"}]
.",
+ "testString":
+ "assert.deepEqual(filteredList, [{\"title\": \"Inception\",\"rating\": \"8.8\"},{\"title\": \"Interstellar\",\"rating\": \"8.6\"},{\"title\": \"The Dark Knight\",\"rating\": \"9.0\"},{\"title\": \"Batman Begins\",\"rating\": \"8.3\"}], 'filteredList
should equal [{\"title\": \"Inception\",\"rating\": \"8.8\"},{\"title\": \"Interstellar\",\"rating\": \"8.6\"},{\"title\": \"The Dark Knight\",\"rating\": \"9.0\"},{\"title\": \"Batman Begins\",\"rating\": \"8.3\"}]
.');"
}
],
"solutions": [],
@@ -824,11 +867,13 @@
"tests": [
{
"text": "new_s
should equal [23, 65, 5]
.",
- "testString": "assert(JSON.stringify(new_s) === JSON.stringify([23, 65, 5]), 'new_s
should equal [23, 65, 5]
.');"
+ "testString":
+ "assert(JSON.stringify(new_s) === JSON.stringify([23, 65, 5]), 'new_s
should equal [23, 65, 5]
.');"
},
{
"text": "Your code should not use the filter
method.",
- "testString": "assert(!code.match(/\\.filter/g), 'Your code should not use the filter
method.');"
+ "testString":
+ "assert(!code.match(/\\.filter/g), 'Your code should not use the filter
method.');"
}
],
"solutions": [],
@@ -875,23 +920,31 @@
"tests": [
{
"text": "Your code should use the slice
method.",
- "testString": "assert(code.match(/\\.slice/g), 'Your code should use the slice
method.');"
+ "testString":
+ "assert(code.match(/\\.slice/g), 'Your code should use the slice
method.');"
},
{
"text": "The inputAnim
variable should not change.",
- "testString": "assert(JSON.stringify(inputAnim) === JSON.stringify([\"Cat\", \"Dog\", \"Tiger\", \"Zebra\", \"Ant\"]), 'The inputAnim
variable should not change.');"
+ "testString":
+ "assert(JSON.stringify(inputAnim) === JSON.stringify([\"Cat\", \"Dog\", \"Tiger\", \"Zebra\", \"Ant\"]), 'The inputAnim
variable should not change.');"
},
{
- "text": "sliceArray([\"Cat\", \"Dog\", \"Tiger\", \"Zebra\", \"Ant\"], 1, 3)
should return [\"Dog\", \"Tiger\"]
.",
- "testString": "assert(JSON.stringify(sliceArray([\"Cat\", \"Dog\", \"Tiger\", \"Zebra\", \"Ant\"], 1, 3)) === JSON.stringify([\"Dog\", \"Tiger\"]), 'sliceArray([\"Cat\", \"Dog\", \"Tiger\", \"Zebra\", \"Ant\"], 1, 3)
should return [\"Dog\", \"Tiger\"]
.');"
+ "text":
+ "sliceArray([\"Cat\", \"Dog\", \"Tiger\", \"Zebra\", \"Ant\"], 1, 3)
should return [\"Dog\", \"Tiger\"]
.",
+ "testString":
+ "assert(JSON.stringify(sliceArray([\"Cat\", \"Dog\", \"Tiger\", \"Zebra\", \"Ant\"], 1, 3)) === JSON.stringify([\"Dog\", \"Tiger\"]), 'sliceArray([\"Cat\", \"Dog\", \"Tiger\", \"Zebra\", \"Ant\"], 1, 3)
should return [\"Dog\", \"Tiger\"]
.');"
},
{
- "text": "sliceArray([\"Cat\", \"Dog\", \"Tiger\", \"Zebra\", \"Ant\"], 0, 1)
should return [\"Cat\"]
.",
- "testString": "assert(JSON.stringify(sliceArray([\"Cat\", \"Dog\", \"Tiger\", \"Zebra\", \"Ant\"], 0, 1)) === JSON.stringify([\"Cat\"]), 'sliceArray([\"Cat\", \"Dog\", \"Tiger\", \"Zebra\", \"Ant\"], 0, 1)
should return [\"Cat\"]
.');"
+ "text":
+ "sliceArray([\"Cat\", \"Dog\", \"Tiger\", \"Zebra\", \"Ant\"], 0, 1)
should return [\"Cat\"]
.",
+ "testString":
+ "assert(JSON.stringify(sliceArray([\"Cat\", \"Dog\", \"Tiger\", \"Zebra\", \"Ant\"], 0, 1)) === JSON.stringify([\"Cat\"]), 'sliceArray([\"Cat\", \"Dog\", \"Tiger\", \"Zebra\", \"Ant\"], 0, 1)
should return [\"Cat\"]
.');"
},
{
- "text": "sliceArray([\"Cat\", \"Dog\", \"Tiger\", \"Zebra\", \"Ant\"], 1, 4)
should return [\"Dog\", \"Tiger\", \"Zebra\"]
.",
- "testString": "assert(JSON.stringify(sliceArray([\"Cat\", \"Dog\", \"Tiger\", \"Zebra\", \"Ant\"], 1, 4)) === JSON.stringify([\"Dog\", \"Tiger\", \"Zebra\"]), 'sliceArray([\"Cat\", \"Dog\", \"Tiger\", \"Zebra\", \"Ant\"], 1, 4)
should return [\"Dog\", \"Tiger\", \"Zebra\"]
.');"
+ "text":
+ "sliceArray([\"Cat\", \"Dog\", \"Tiger\", \"Zebra\", \"Ant\"], 1, 4)
should return [\"Dog\", \"Tiger\", \"Zebra\"]
.",
+ "testString":
+ "assert(JSON.stringify(sliceArray([\"Cat\", \"Dog\", \"Tiger\", \"Zebra\", \"Ant\"], 1, 4)) === JSON.stringify([\"Dog\", \"Tiger\", \"Zebra\"]), 'sliceArray([\"Cat\", \"Dog\", \"Tiger\", \"Zebra\", \"Ant\"], 1, 4)
should return [\"Dog\", \"Tiger\", \"Zebra\"]
.');"
}
],
"solutions": [],
@@ -932,19 +985,24 @@
"tests": [
{
"text": "Your code should use the slice
method.",
- "testString": "assert(code.match(/\\.slice/g), 'Your code should use the slice
method.');"
+ "testString":
+ "assert(code.match(/\\.slice/g), 'Your code should use the slice
method.');"
},
{
"text": "Your code should not use the splice
method.",
- "testString": "assert(!code.match(/\\.splice/g), 'Your code should not use the splice
method.');"
+ "testString":
+ "assert(!code.match(/\\.splice/g), 'Your code should not use the splice
method.');"
},
{
"text": "The inputCities
array should not change.",
- "testString": "assert(JSON.stringify(inputCities) === JSON.stringify([\"Chicago\", \"Delhi\", \"Islamabad\", \"London\", \"Berlin\"]), 'The inputCities
array should not change.');"
+ "testString":
+ "assert(JSON.stringify(inputCities) === JSON.stringify([\"Chicago\", \"Delhi\", \"Islamabad\", \"London\", \"Berlin\"]), 'The inputCities
array should not change.');"
},
{
- "text": "nonMutatingSplice([\"Chicago\", \"Delhi\", \"Islamabad\", \"London\", \"Berlin\"])
should return [\"Chicago\", \"Delhi\", \"Islamabad\"]
.",
- "testString": "assert(JSON.stringify(nonMutatingSplice([\"Chicago\", \"Delhi\", \"Islamabad\", \"London\", \"Berlin\"])) === JSON.stringify([\"Chicago\", \"Delhi\", \"Islamabad\"]), 'nonMutatingSplice([\"Chicago\", \"Delhi\", \"Islamabad\", \"London\", \"Berlin\"])
should return [\"Chicago\", \"Delhi\", \"Islamabad\"]
.');"
+ "text":
+ "nonMutatingSplice([\"Chicago\", \"Delhi\", \"Islamabad\", \"London\", \"Berlin\"])
should return [\"Chicago\", \"Delhi\", \"Islamabad\"]
.",
+ "testString":
+ "assert(JSON.stringify(nonMutatingSplice([\"Chicago\", \"Delhi\", \"Islamabad\", \"London\", \"Berlin\"])) === JSON.stringify([\"Chicago\", \"Delhi\", \"Islamabad\"]), 'nonMutatingSplice([\"Chicago\", \"Delhi\", \"Islamabad\", \"London\", \"Berlin\"])
should return [\"Chicago\", \"Delhi\", \"Islamabad\"]
.');"
}
],
"solutions": [],
@@ -983,19 +1041,24 @@
"tests": [
{
"text": "Your code should use the concat
method.",
- "testString": "assert(code.match(/\\.concat/g), 'Your code should use the concat
method.');"
+ "testString":
+ "assert(code.match(/\\.concat/g), 'Your code should use the concat
method.');"
},
{
"text": "The first
array should not change.",
- "testString": "assert(JSON.stringify(first) === JSON.stringify([1, 2, 3]), 'The first
array should not change.');"
+ "testString":
+ "assert(JSON.stringify(first) === JSON.stringify([1, 2, 3]), 'The first
array should not change.');"
},
{
"text": "The second
array should not change.",
- "testString": "assert(JSON.stringify(second) === JSON.stringify([4, 5]), 'The second
array should not change.');"
+ "testString":
+ "assert(JSON.stringify(second) === JSON.stringify([4, 5]), 'The second
array should not change.');"
},
{
- "text": "nonMutatingConcat([1, 2, 3], [4, 5])
should return [1, 2, 3, 4, 5]
.",
- "testString": "assert(JSON.stringify(nonMutatingConcat([1, 2, 3], [4, 5])) === JSON.stringify([1, 2, 3, 4, 5]), 'nonMutatingConcat([1, 2, 3], [4, 5])
should return [1, 2, 3, 4, 5]
.');"
+ "text":
+ "nonMutatingConcat([1, 2, 3], [4, 5])
should return [1, 2, 3, 4, 5]
.",
+ "testString":
+ "assert(JSON.stringify(nonMutatingConcat([1, 2, 3], [4, 5])) === JSON.stringify([1, 2, 3, 4, 5]), 'nonMutatingConcat([1, 2, 3], [4, 5])
should return [1, 2, 3, 4, 5]
.');"
}
],
"solutions": [],
@@ -1025,7 +1088,8 @@
},
{
"id": "587d7da9367417b2b2512b67",
- "title": "Add Elements to the End of an Array Using concat Instead of push",
+ "title":
+ "Add Elements to the End of an Array Using concat Instead of push",
"description": [
"Functional programming is all about creating and using non-mutating functions.",
"The last challenge introduced the concat
method as a way to combine arrays into a new one without mutating the original arrays. Compare concat
to the push
method. Push
adds an item to the end of the same array it is called on, which mutates that array. Here's an example:",
@@ -1037,23 +1101,29 @@
"tests": [
{
"text": "Your code should use the concat
method.",
- "testString": "assert(code.match(/\\.concat/g), 'Your code should use the concat
method.');"
+ "testString":
+ "assert(code.match(/\\.concat/g), 'Your code should use the concat
method.');"
},
{
"text": "Your code should not use the push
method.",
- "testString": "assert(!code.match(/\\.push/g), 'Your code should not use the push
method.');"
+ "testString":
+ "assert(!code.match(/\\.push/g), 'Your code should not use the push
method.');"
},
{
"text": "The first
array should not change.",
- "testString": "assert(JSON.stringify(first) === JSON.stringify([1, 2, 3]), 'The first
array should not change.');"
+ "testString":
+ "assert(JSON.stringify(first) === JSON.stringify([1, 2, 3]), 'The first
array should not change.');"
},
{
"text": "The second
array should not change.",
- "testString": "assert(JSON.stringify(second) === JSON.stringify([4, 5]), 'The second
array should not change.');"
+ "testString":
+ "assert(JSON.stringify(second) === JSON.stringify([4, 5]), 'The second
array should not change.');"
},
{
- "text": "nonMutatingPush([1, 2, 3], [4, 5])
should return [1, 2, 3, 4, 5]
.",
- "testString": "assert(JSON.stringify(nonMutatingPush([1, 2, 3], [4, 5])) === JSON.stringify([1, 2, 3, 4, 5]), 'nonMutatingPush([1, 2, 3], [4, 5])
should return [1, 2, 3, 4, 5]
.');"
+ "text":
+ "nonMutatingPush([1, 2, 3], [4, 5])
should return [1, 2, 3, 4, 5]
.",
+ "testString":
+ "assert(JSON.stringify(nonMutatingPush([1, 2, 3], [4, 5])) === JSON.stringify([1, 2, 3, 4, 5]), 'nonMutatingPush([1, 2, 3], [4, 5])
should return [1, 2, 3, 4, 5]
.');"
}
],
"solutions": [],
@@ -1095,19 +1165,23 @@
"tests": [
{
"text": "The watchList
variable should not change.",
- "testString": "assert(watchList[0].Title === \"Inception\" && watchList[4].Director == \"James Cameron\", 'The watchList
variable should not change.');"
+ "testString":
+ "assert(watchList[0].Title === \"Inception\" && watchList[4].Director == \"James Cameron\", 'The watchList
variable should not change.');"
},
{
"text": "Your code should use the reduce
method.",
- "testString": "assert(code.match(/\\.reduce/g), 'Your code should use the reduce
method.');"
+ "testString":
+ "assert(code.match(/\\.reduce/g), 'Your code should use the reduce
method.');"
},
{
"text": "The averageRating
should equal 8.675.",
- "testString": "assert(averageRating == 8.675, 'The averageRating
should equal 8.675.');"
+ "testString":
+ "assert(averageRating == 8.675, 'The averageRating
should equal 8.675.');"
},
{
"text": "Your code should not use a for
loop.",
- "testString": "assert(!code.match(/for\\s*?\\(.*\\)/g), 'Your code should not use a for
loop.');"
+ "testString":
+ "assert(!code.match(/for\\s*?\\(.*\\)/g), 'Your code should not use a for
loop.');"
}
],
"solutions": [],
@@ -1265,19 +1339,26 @@
"tests": [
{
"text": "Your code should use the sort
method.",
- "testString": "assert(code.match(/\\.sort/g), 'Your code should use the sort
method.');"
+ "testString":
+ "assert(code.match(/\\.sort/g), 'Your code should use the sort
method.');"
},
{
- "text": "alphabeticalOrder([\"a\", \"d\", \"c\", \"a\", \"z\", \"g\"])
should return [\"a\", \"a\", \"c\", \"d\", \"g\", \"z\"]
.",
- "testString": "assert(JSON.stringify(alphabeticalOrder([\"a\", \"d\", \"c\", \"a\", \"z\", \"g\"])) === JSON.stringify([\"a\", \"a\", \"c\", \"d\", \"g\", \"z\"]), 'alphabeticalOrder([\"a\", \"d\", \"c\", \"a\", \"z\", \"g\"])
should return [\"a\", \"a\", \"c\", \"d\", \"g\", \"z\"]
.');"
+ "text":
+ "alphabeticalOrder([\"a\", \"d\", \"c\", \"a\", \"z\", \"g\"])
should return [\"a\", \"a\", \"c\", \"d\", \"g\", \"z\"]
.",
+ "testString":
+ "assert(JSON.stringify(alphabeticalOrder([\"a\", \"d\", \"c\", \"a\", \"z\", \"g\"])) === JSON.stringify([\"a\", \"a\", \"c\", \"d\", \"g\", \"z\"]), 'alphabeticalOrder([\"a\", \"d\", \"c\", \"a\", \"z\", \"g\"])
should return [\"a\", \"a\", \"c\", \"d\", \"g\", \"z\"]
.');"
},
{
- "text": "alphabeticalOrder([\"x\", \"h\", \"a\", \"m\", \"n\", \"m\"])
should return [\"a\", \"h\", \"m\", \"m\", \"n\", \"x\"]
.",
- "testString": "assert(JSON.stringify(alphabeticalOrder([\"x\", \"h\", \"a\", \"m\", \"n\", \"m\"])) === JSON.stringify([\"a\", \"h\", \"m\", \"m\", \"n\", \"x\"]), 'alphabeticalOrder([\"x\", \"h\", \"a\", \"m\", \"n\", \"m\"])
should return [\"a\", \"h\", \"m\", \"m\", \"n\", \"x\"]
.');"
+ "text":
+ "alphabeticalOrder([\"x\", \"h\", \"a\", \"m\", \"n\", \"m\"])
should return [\"a\", \"h\", \"m\", \"m\", \"n\", \"x\"]
.",
+ "testString":
+ "assert(JSON.stringify(alphabeticalOrder([\"x\", \"h\", \"a\", \"m\", \"n\", \"m\"])) === JSON.stringify([\"a\", \"h\", \"m\", \"m\", \"n\", \"x\"]), 'alphabeticalOrder([\"x\", \"h\", \"a\", \"m\", \"n\", \"m\"])
should return [\"a\", \"h\", \"m\", \"m\", \"n\", \"x\"]
.');"
},
{
- "text": "alphabeticalOrder([\"a\", \"a\", \"a\", \"a\", \"x\", \"t\"])
should return [\"a\", \"a\", \"a\", \"a\", \"t\", \"x\"]
.",
- "testString": "assert(JSON.stringify(alphabeticalOrder([\"a\", \"a\", \"a\", \"a\", \"x\", \"t\"])) === JSON.stringify([\"a\", \"a\", \"a\", \"a\", \"t\", \"x\"]), 'alphabeticalOrder([\"a\", \"a\", \"a\", \"a\", \"x\", \"t\"])
should return [\"a\", \"a\", \"a\", \"a\", \"t\", \"x\"]
.');"
+ "text":
+ "alphabeticalOrder([\"a\", \"a\", \"a\", \"a\", \"x\", \"t\"])
should return [\"a\", \"a\", \"a\", \"a\", \"t\", \"x\"]
.",
+ "testString":
+ "assert(JSON.stringify(alphabeticalOrder([\"a\", \"a\", \"a\", \"a\", \"x\", \"t\"])) === JSON.stringify([\"a\", \"a\", \"a\", \"a\", \"t\", \"x\"]), 'alphabeticalOrder([\"a\", \"a\", \"a\", \"a\", \"x\", \"t\"])
should return [\"a\", \"a\", \"a\", \"a\", \"t\", \"x\"]
.');"
}
],
"solutions": [],
@@ -1314,19 +1395,24 @@
"tests": [
{
"text": "Your code should use the sort
method.",
- "testString": "assert(code.match(/\\.sort/g), 'Your code should use the sort
method.');"
+ "testString":
+ "assert(code.match(/\\.sort/g), 'Your code should use the sort
method.');"
},
{
"text": "Your code should use the concat
method.",
- "testString": "assert(code.match(/\\.concat/g), 'Your code should use the concat
method.');"
+ "testString":
+ "assert(code.match(/\\.concat/g), 'Your code should use the concat
method.');"
},
{
"text": "The globalArray
variable should not change.",
- "testString": "assert(JSON.stringify(globalArray) === JSON.stringify([5, 6, 3, 2, 9]), 'The globalArray
variable should not change.');"
+ "testString":
+ "assert(JSON.stringify(globalArray) === JSON.stringify([5, 6, 3, 2, 9]), 'The globalArray
variable should not change.');"
},
{
- "text": "nonMutatingSort(globalArray)
should return [2, 3, 5, 6, 9]
.",
- "testString": "assert(JSON.stringify(nonMutatingSort(globalArray)) === JSON.stringify([2, 3, 5, 6, 9]), 'nonMutatingSort(globalArray)
should return [2, 3, 5, 6, 9]
.');"
+ "text":
+ "nonMutatingSort(globalArray)
should return [2, 3, 5, 6, 9]
.",
+ "testString":
+ "assert(JSON.stringify(nonMutatingSort(globalArray)) === JSON.stringify([2, 3, 5, 6, 9]), 'nonMutatingSort(globalArray)
should return [2, 3, 5, 6, 9]
.');"
}
],
"solutions": [],
@@ -1359,7 +1445,7 @@
"description": [
"The split
method splits a string into an array of strings. It takes an argument for the delimiter, which can be a character to use to break up the string or a regular expression. For example, if the delimiter is a space, you get an array of words, and if the delimiter is an empty string, you get an array of each character in the string.",
"Here are two examples that split one string by spaces, then another by digits using a regular expression:",
- "
var str = \"Hello World\";", + "
var bySpace = str.split(\" \");
// Sets bySpace to [\"Hello\", \"World\"]
var otherString = \"How9are7you2today\";
var byDigits = str.split(/\\d/);
// Sets byDigits to [\"How\", \"are\", \"you\", \"today\"]
var str = \"Hello World\";", "Since strings are immutable, the
var bySpace = str.split(\" \");
// Sets bySpace to [\"Hello\", \"World\"]
var otherString = \"How9are7you2today\";
var byDigits = otherString.split(/\\d/);
// Sets byDigits to [\"How\", \"are\", \"you\", \"today\"]
split
method makes it easier to work with them.",
"split
method inside the splitify
function to split str
into an array of words. The function should return the array. Note that the words are not always separated by spaces, and the array should not contain punctuation."
@@ -1367,19 +1453,26 @@
"tests": [
{
"text": "Your code should use the split
method.",
- "testString": "assert(code.match(/\\.split/g), 'Your code should use the split
method.');"
+ "testString":
+ "assert(code.match(/\\.split/g), 'Your code should use the split
method.');"
},
{
- "text": "splitify(\"Hello World,I-am code\")
should return [\"Hello\", \"World\", \"I\", \"am\", \"code\"]
.",
- "testString": "assert(JSON.stringify(splitify(\"Hello World,I-am code\")) === JSON.stringify([\"Hello\", \"World\", \"I\", \"am\", \"code\"]), 'splitify(\"Hello World,I-am code\")
should return [\"Hello\", \"World\", \"I\", \"am\", \"code\"]
.');"
+ "text":
+ "splitify(\"Hello World,I-am code\")
should return [\"Hello\", \"World\", \"I\", \"am\", \"code\"]
.",
+ "testString":
+ "assert(JSON.stringify(splitify(\"Hello World,I-am code\")) === JSON.stringify([\"Hello\", \"World\", \"I\", \"am\", \"code\"]), 'splitify(\"Hello World,I-am code\")
should return [\"Hello\", \"World\", \"I\", \"am\", \"code\"]
.');"
},
{
- "text": "splitify(\"Earth-is-our home\")
should return [\"Earth\", \"is\", \"our\", \"home\"]
.",
- "testString": "assert(JSON.stringify(splitify(\"Earth-is-our home\")) === JSON.stringify([\"Earth\", \"is\", \"our\", \"home\"]), 'splitify(\"Earth-is-our home\")
should return [\"Earth\", \"is\", \"our\", \"home\"]
.');"
+ "text":
+ "splitify(\"Earth-is-our home\")
should return [\"Earth\", \"is\", \"our\", \"home\"]
.",
+ "testString":
+ "assert(JSON.stringify(splitify(\"Earth-is-our home\")) === JSON.stringify([\"Earth\", \"is\", \"our\", \"home\"]), 'splitify(\"Earth-is-our home\")
should return [\"Earth\", \"is\", \"our\", \"home\"]
.');"
},
{
- "text": "splitify(\"This.is.a-sentence\")
should return [\"This\", \"is\", \"a\", \"sentence\"]
.",
- "testString": "assert(JSON.stringify(splitify(\"This.is.a-sentence\")) === JSON.stringify([\"This\", \"is\", \"a\", \"sentence\"]), 'splitify(\"This.is.a-sentence\")
should return [\"This\", \"is\", \"a\", \"sentence\"]
.');"
+ "text":
+ "splitify(\"This.is.a-sentence\")
should return [\"This\", \"is\", \"a\", \"sentence\"]
.",
+ "testString":
+ "assert(JSON.stringify(splitify(\"This.is.a-sentence\")) === JSON.stringify([\"This\", \"is\", \"a\", \"sentence\"]), 'splitify(\"This.is.a-sentence\")
should return [\"This\", \"is\", \"a\", \"sentence\"]
.');"
}
],
"solutions": [],
@@ -1420,27 +1513,37 @@
"tests": [
{
"text": "Your code should use the join
method.",
- "testString": "assert(code.match(/\\.join/g), 'Your code should use the join
method.');"
+ "testString":
+ "assert(code.match(/\\.join/g), 'Your code should use the join
method.');"
},
{
"text": "Your code should not use the replace
method.",
- "testString": "assert(!code.match(/\\.replace/g), 'Your code should not use the replace
method.');"
+ "testString":
+ "assert(!code.match(/\\.replace/g), 'Your code should not use the replace
method.');"
},
{
- "text": "sentensify(\"May-the-force-be-with-you\")
should return a string.",
- "testString": "assert(typeof sentensify(\"May-the-force-be-with-you\") === \"string\", 'sentensify(\"May-the-force-be-with-you\")
should return a string.');"
+ "text":
+ "sentensify(\"May-the-force-be-with-you\")
should return a string.",
+ "testString":
+ "assert(typeof sentensify(\"May-the-force-be-with-you\") === \"string\", 'sentensify(\"May-the-force-be-with-you\")
should return a string.');"
},
{
- "text": "sentensify(\"May-the-force-be-with-you\")
should return \"May the force be with you\"
.",
- "testString": "assert(sentensify(\"May-the-force-be-with-you\") === \"May the force be with you\", 'sentensify(\"May-the-force-be-with-you\")
should return \"May the force be with you\"
.');"
+ "text":
+ "sentensify(\"May-the-force-be-with-you\")
should return \"May the force be with you\"
.",
+ "testString":
+ "assert(sentensify(\"May-the-force-be-with-you\") === \"May the force be with you\", 'sentensify(\"May-the-force-be-with-you\")
should return \"May the force be with you\"
.');"
},
{
- "text": "sentensify(\"The.force.is.strong.with.this.one\")
should return \"The force is strong with this one\"
.",
- "testString": "assert(sentensify(\"The.force.is.strong.with.this.one\") === \"The force is strong with this one\", 'sentensify(\"The.force.is.strong.with.this.one\")
should return \"The force is strong with this one\"
.');"
+ "text":
+ "sentensify(\"The.force.is.strong.with.this.one\")
should return \"The force is strong with this one\"
.",
+ "testString":
+ "assert(sentensify(\"The.force.is.strong.with.this.one\") === \"The force is strong with this one\", 'sentensify(\"The.force.is.strong.with.this.one\")
should return \"The force is strong with this one\"
.');"
},
{
- "text": "sentensify(\"There,has,been,an,awakening\")
should return \"There has been an awakening\"
.",
- "testString": "assert(sentensify(\"There,has,been,an,awakening\") === \"There has been an awakening\", 'sentensify(\"There,has,been,an,awakening\")
should return \"There has been an awakening\"
.');"
+ "text":
+ "sentensify(\"There,has,been,an,awakening\")
should return \"There has been an awakening\"
.",
+ "testString":
+ "assert(sentensify(\"There,has,been,an,awakening\") === \"There has been an awakening\", 'sentensify(\"There,has,been,an,awakening\")
should return \"There has been an awakening\"
.');"
}
],
"solutions": [],
@@ -1485,27 +1588,38 @@
"tests": [
{
"text": "The globalTitle
variable should not change.",
- "testString": "assert(globalTitle === \"Winter Is Coming\", 'The globalTitle
variable should not change.');"
+ "testString":
+ "assert(globalTitle === \"Winter Is Coming\", 'The globalTitle
variable should not change.');"
},
{
- "text": "Your code should not use the replace
method for this challenge.",
- "testString": "assert(!code.match(/\\.replace/g), 'Your code should not use the replace
method for this challenge.');"
+ "text":
+ "Your code should not use the replace
method for this challenge.",
+ "testString":
+ "assert(!code.match(/\\.replace/g), 'Your code should not use the replace
method for this challenge.');"
},
{
- "text": "urlSlug(\"Winter Is Coming\")
should return \"winter-is-coming\"
.",
- "testString": "assert(urlSlug(\"Winter Is Coming\") === \"winter-is-coming\", 'urlSlug(\"Winter Is Coming\")
should return \"winter-is-coming\"
.');"
+ "text":
+ "urlSlug(\"Winter Is Coming\")
should return \"winter-is-coming\"
.",
+ "testString":
+ "assert(urlSlug(\"Winter Is Coming\") === \"winter-is-coming\", 'urlSlug(\"Winter Is Coming\")
should return \"winter-is-coming\"
.');"
},
{
- "text": "urlSlug(\" Winter Is Coming\")
should return \"winter-is-coming\"
.",
- "testString": "assert(urlSlug(\" Winter Is Coming\") === \"winter-is-coming\", 'urlSlug(\" Winter Is Coming\")
should return \"winter-is-coming\"
.');"
+ "text":
+ "urlSlug(\" Winter Is Coming\")
should return \"winter-is-coming\"
.",
+ "testString":
+ "assert(urlSlug(\" Winter Is Coming\") === \"winter-is-coming\", 'urlSlug(\" Winter Is Coming\")
should return \"winter-is-coming\"
.');"
},
{
- "text": "urlSlug(\"A Mind Needs Books Like A Sword Needs A Whetstone\")
should return \"a-mind-needs-books-like-a-sword-needs-a-whetstone\"
.",
- "testString": "assert(urlSlug(\"A Mind Needs Books Like A Sword Needs A Whetstone\") === \"a-mind-needs-books-like-a-sword-needs-a-whetstone\", 'urlSlug(\"A Mind Needs Books Like A Sword Needs A Whetstone\")
should return \"a-mind-needs-books-like-a-sword-needs-a-whetstone\"
.');"
+ "text":
+ "urlSlug(\"A Mind Needs Books Like A Sword Needs A Whetstone\")
should return \"a-mind-needs-books-like-a-sword-needs-a-whetstone\"
.",
+ "testString":
+ "assert(urlSlug(\"A Mind Needs Books Like A Sword Needs A Whetstone\") === \"a-mind-needs-books-like-a-sword-needs-a-whetstone\", 'urlSlug(\"A Mind Needs Books Like A Sword Needs A Whetstone\")
should return \"a-mind-needs-books-like-a-sword-needs-a-whetstone\"
.');"
},
{
- "text": "urlSlug(\"Hold The Door\")
should return \"hold-the-door\"
.",
- "testString": "assert(urlSlug(\"Hold The Door\") === \"hold-the-door\", 'urlSlug(\"Hold The Door\")
should return \"hold-the-door\"
.');"
+ "text":
+ "urlSlug(\"Hold The Door\")
should return \"hold-the-door\"
.",
+ "testString":
+ "assert(urlSlug(\"Hold The Door\") === \"hold-the-door\", 'urlSlug(\"Hold The Door\")
should return \"hold-the-door\"
.');"
}
],
"solutions": [],
@@ -1540,7 +1654,8 @@
},
{
"id": "587d7dab367417b2b2512b6e",
- "title": "Use the every Method to Check that Every Element in an Array Meets a Criteria",
+ "title":
+ "Use the every Method to Check that Every Element in an Array Meets a Criteria",
"description": [
"The every
method works with arrays to check if every element passes a particular test. It returns a Boolean value - true
if all values meet the criteria, false
if not.",
"For example, the following code would check if every element in the numbers
array is less than 10:",
@@ -1551,19 +1666,26 @@
"tests": [
{
"text": "Your code should use the every
method.",
- "testString": "assert(code.match(/\\.every/g), 'Your code should use the every
method.');"
+ "testString":
+ "assert(code.match(/\\.every/g), 'Your code should use the every
method.');"
},
{
- "text": "checkPositive([1, 2, 3, -4, 5])
should return false
.",
- "testString": "assert(!checkPositive([1, 2, 3, -4, 5]), 'checkPositive([1, 2, 3, -4, 5])
should return false
.');"
+ "text":
+ "checkPositive([1, 2, 3, -4, 5])
should return false
.",
+ "testString":
+ "assert(!checkPositive([1, 2, 3, -4, 5]), 'checkPositive([1, 2, 3, -4, 5])
should return false
.');"
},
{
- "text": "checkPositive([1, 2, 3, 4, 5])
should return true
.",
- "testString": "assert(checkPositive([1, 2, 3, 4, 5]), 'checkPositive([1, 2, 3, 4, 5])
should return true
.');"
+ "text":
+ "checkPositive([1, 2, 3, 4, 5])
should return true
.",
+ "testString":
+ "assert(checkPositive([1, 2, 3, 4, 5]), 'checkPositive([1, 2, 3, 4, 5])
should return true
.');"
},
{
- "text": "checkPositive([1, -2, 3, -4, 5])
should return false
.",
- "testString": "assert(!checkPositive([1, -2, 3, -4, 5]), 'checkPositive([1, -2, 3, -4, 5])
should return false
.');"
+ "text":
+ "checkPositive([1, -2, 3, -4, 5])
should return false
.",
+ "testString":
+ "assert(!checkPositive([1, -2, 3, -4, 5]), 'checkPositive([1, -2, 3, -4, 5])
should return false
.');"
}
],
"solutions": [],
@@ -1591,7 +1713,8 @@
},
{
"id": "587d7dab367417b2b2512b6f",
- "title": "Use the some Method to Check that Any Elements in an Array Meet a Criteria",
+ "title":
+ "Use the some Method to Check that Any Elements in an Array Meet a Criteria",
"description": [
"The some
method works with arrays to check if any element passes a particular test. It returns a Boolean value - true
if any of the values meet the criteria, false
if not.",
"For example, the following code would check if any element in the numbers
array is less than 10:",
@@ -1602,19 +1725,26 @@
"tests": [
{
"text": "Your code should use the some
method.",
- "testString": "assert(code.match(/\\.some/g), 'Your code should use the some
method.');"
+ "testString":
+ "assert(code.match(/\\.some/g), 'Your code should use the some
method.');"
},
{
- "text": "checkPositive([1, 2, 3, -4, 5])
should return true
.",
- "testString": "assert(checkPositive([1, 2, 3, -4, 5]), 'checkPositive([1, 2, 3, -4, 5])
should return true
.');"
+ "text":
+ "checkPositive([1, 2, 3, -4, 5])
should return true
.",
+ "testString":
+ "assert(checkPositive([1, 2, 3, -4, 5]), 'checkPositive([1, 2, 3, -4, 5])
should return true
.');"
},
{
- "text": "checkPositive([1, 2, 3, 4, 5])
should return true
.",
- "testString": "assert(checkPositive([1, 2, 3, 4, 5]), 'checkPositive([1, 2, 3, 4, 5])
should return true
.');"
+ "text":
+ "checkPositive([1, 2, 3, 4, 5])
should return true
.",
+ "testString":
+ "assert(checkPositive([1, 2, 3, 4, 5]), 'checkPositive([1, 2, 3, 4, 5])
should return true
.');"
},
{
- "text": "checkPositive([-1, -2, -3, -4, -5])
should return false
.",
- "testString": "assert(!checkPositive([-1, -2, -3, -4, -5]), 'checkPositive([-1, -2, -3, -4, -5])
should return false
.');"
+ "text":
+ "checkPositive([-1, -2, -3, -4, -5])
should return false
.",
+ "testString":
+ "assert(!checkPositive([-1, -2, -3, -4, -5]), 'checkPositive([-1, -2, -3, -4, -5])
should return false
.');"
}
],
"solutions": [],
@@ -1659,19 +1789,24 @@
"tests": [
{
"text": "add(10)(20)(30)
should return 60
.",
- "testString": "assert(add(10)(20)(30) === 60, 'add(10)(20)(30)
should return 60
.');"
+ "testString":
+ "assert(add(10)(20)(30) === 60, 'add(10)(20)(30)
should return 60
.');"
},
{
"text": "add(1)(2)(3)
should return 6
.",
- "testString": "assert(add(1)(2)(3) === 6, 'add(1)(2)(3)
should return 6
.');"
+ "testString":
+ "assert(add(1)(2)(3) === 6, 'add(1)(2)(3)
should return 6
.');"
},
{
"text": "add(11)(22)(33)
should return 66
.",
- "testString": "assert(add(11)(22)(33) === 66, 'add(11)(22)(33)
should return 66
.');"
+ "testString":
+ "assert(add(11)(22)(33) === 66, 'add(11)(22)(33)
should return 66
.');"
},
{
- "text": "Your code should include a final statement that returns x + y + z
.",
- "testString": "assert(code.match(/[xyz]\\s*?\\+\\s*?[xyz]\\s*?\\+\\s*?[xyz]/g), 'Your code should include a final statement that returns x + y + z
.');"
+ "text":
+ "Your code should include a final statement that returns x + y + z
.",
+ "testString":
+ "assert(code.match(/[xyz]\\s*?\\+\\s*?[xyz]\\s*?\\+\\s*?[xyz]/g), 'Your code should include a final statement that returns x + y + z
.');"
}
],
"solutions": [],