continue refactoring bonfire tests
This commit is contained in:
@ -46,23 +46,23 @@
|
||||
"title": "Reverse a String",
|
||||
"difficulty": "1.01",
|
||||
"tests": [
|
||||
"assert(typeof(reverseString('hello')) === \"string\", '<code>reverseString()</code> should return a string.');",
|
||||
"assert(reverseString('hello') === 'olleh', '\"hello\" should become \"olleh\".');",
|
||||
"assert(reverseString('Howdy') === 'ydwoH', '\"Howdy\" should become \"ydwoH\".');",
|
||||
"assert(reverseString('Greetings from Earth') === 'htraE morf sgniteerG', '\"Greetings from Earth\" should return \"htraE morf sgniteerG\".');"
|
||||
"assert(typeof(reverseString(\"hello\")) === \"string\", '<code>reverseString()</code> should return a string.');",
|
||||
"assert(reverseString(\"hello\") === \"olleh\", '<code>\"hello\"</code> should become <code>\"olleh\"</code>.');",
|
||||
"assert(reverseString(\"Howdy\") === \"ydwoH\", '<code>\"Howdy\"</code> should become <code>\"ydwoH\"</code>.');",
|
||||
"assert(reverseString(\"Greetings from Earth\") === \"htraE morf sgniteerG\", '<code>\"Greetings from Earth\"</code> should return <code>\"htraE morf sgniteerG\"</code>.');"
|
||||
],
|
||||
"description": [
|
||||
"Reverse the provided string.",
|
||||
"You may need to turn the string into an array before you can reverse it.",
|
||||
"Your result must be a string.",
|
||||
"Remember to use <a href='//github.com/FreeCodeCamp/freecodecamp/wiki/How-to-get-help-when-you-get-stuck' target='_blank'>Read-Search-Ask</a> if you get stuck. Write your own code."
|
||||
"Remember to use <a href=\"//github.com/FreeCodeCamp/freecodecamp/wiki/How-to-get-help-when-you-get-stuck\" target=\"_blank\">Read-Search-Ask</a> if you get stuck. Write your own code."
|
||||
],
|
||||
"challengeSeed": [
|
||||
"function reverseString(str) {",
|
||||
" return str;",
|
||||
"}",
|
||||
"",
|
||||
"reverseString('hello', '');"
|
||||
"reverseString(\"hello\", \"\");"
|
||||
],
|
||||
"MDNlinks": [
|
||||
"Global String Object",
|
||||
@ -88,9 +88,9 @@
|
||||
"title": "Factorialize a Number",
|
||||
"tests": [
|
||||
"assert(typeof(factorialize(5)) === \"number\", '<code>factorialize()</code> should return a number.');",
|
||||
"assert(factorialize(5) === 120, '<code>5</code> should return 120</code>.');",
|
||||
"assert(factorialize(10) === 3628800, '<code>10</code> should return <code>3,628,800</code>.');",
|
||||
"assert(factorialize(20) === 2432902008176640000, '<code>20</code> should return <code>2,432,902,008,176,640,000</code>.');"
|
||||
"assert(factorialize(5) === 120, '<code>5</code> should return <code>120</code>.');",
|
||||
"assert(factorialize(10) === 3628800, '<code>10</code> should return <code>3,628,800</code>.');",
|
||||
"assert(factorialize(20) === 2432902008176640000, '<code>20</code> should return <code>2,432,902,008,176,640,000</code>.');"
|
||||
],
|
||||
"difficulty": "1.02",
|
||||
"description": [
|
||||
@ -98,7 +98,7 @@
|
||||
"If the integer is represented with the letter n, a factorial is the product of all positive integers less than or equal to n.",
|
||||
"Factorials are often represented with the shorthand notation <code>n!</code>",
|
||||
"For example: <code>5! = 1 * 2 * 3 * 4 * 5 = 120</code>",
|
||||
"Remember to use <a href='//github.com/FreeCodeCamp/freecodecamp/wiki/How-to-get-help-when-you-get-stuck' target='_blank'>Read-Search-Ask</a> if you get stuck. Write your own code."
|
||||
"Remember to use <a href=\"//github.com/FreeCodeCamp/freecodecamp/wiki/How-to-get-help-when-you-get-stuck\" target=\"_blank\">Read-Search-Ask</a> if you get stuck. Write your own code."
|
||||
],
|
||||
"challengeSeed": [
|
||||
"function factorialize(num) {",
|
||||
@ -132,17 +132,17 @@
|
||||
"A palindrome is a word or sentence that's spelled the same way both forward and backward, ignoring punctuation, case, and spacing.",
|
||||
"You'll need to remove punctuation and turn everything lower case in order to check for palindromes.",
|
||||
"We'll pass strings with varying formats, such as \"racecar\", \"RaceCar\", and \"race CAR\" among others.",
|
||||
"Remember to use <a href='//github.com/FreeCodeCamp/freecodecamp/wiki/How-to-get-help-when-you-get-stuck' target='_blank'>Read-Search-Ask</a> if you get stuck. Write your own code."
|
||||
"Remember to use <a href=\"//github.com/FreeCodeCamp/freecodecamp/wiki/How-to-get-help-when-you-get-stuck\" target=\"_blank\">Read-Search-Ask</a> if you get stuck. Write your own code."
|
||||
],
|
||||
"tests": [
|
||||
"assert(typeof(palindrome(\"eye\")) === \"boolean\", '<code>palindrome()<code> should return a boolean.');",
|
||||
"assert(palindrome(\"eye\") === true, '\"eye\" should return true.');",
|
||||
"assert(palindrome(\"race car\") === true, '\"race car\" should return true.');",
|
||||
"assert(palindrome(\"not a palindrome\") === false, '\"not a palindrome\" should return false.');",
|
||||
"assert(palindrome(\"A man, a plan, a canal. Panama\") === true, '\"A man, a plan, a canal. Panama\" should return true.');",
|
||||
"assert(palindrome(\"never odd or even\") === true, '\"never odd or even\" should return true.');",
|
||||
"assert(palindrome(\"nope\") === false, '\"nope\" should return false.');",
|
||||
"assert(palindrome(\"almostomla\") === false, '\"almostomla\" should return false.');"
|
||||
"assert(palindrome(\"eye\") === true, '<code>\"eye\"</code> should return true.');",
|
||||
"assert(palindrome(\"race car\") === true, '<code>\"race car\"</code> should return true.');",
|
||||
"assert(palindrome(\"not a palindrome\") === false, '<code>\"not a palindrome\"</code> should return false.');",
|
||||
"assert(palindrome(\"A man, a plan, a canal. Panama\") === true, '<code>\"A man, a plan, a canal. Panama\"</code> should return true.');",
|
||||
"assert(palindrome(\"never odd or even\") === true, '<code>\"never odd or even\"</code> should return true.');",
|
||||
"assert(palindrome(\"nope\") === false, '<code>\"nope\"</code> should return false.');",
|
||||
"assert(palindrome(\"almostomla\") === false, '<code>\"almostomla\"</code> should return false.');"
|
||||
],
|
||||
"challengeSeed": [
|
||||
"function palindrome(str) {",
|
||||
@ -178,22 +178,22 @@
|
||||
"description": [
|
||||
"Return the length of the longest word in the provided sentence.",
|
||||
"Your response should be a number.",
|
||||
"Remember to use <a href='//github.com/FreeCodeCamp/freecodecamp/wiki/How-to-get-help-when-you-get-stuck' target='_blank'>Read-Search-Ask</a> if you get stuck. Write your own code."
|
||||
"Remember to use <a href=\"//github.com/FreeCodeCamp/freecodecamp/wiki/How-to-get-help-when-you-get-stuck\" target=\"_blank\">Read-Search-Ask</a> if you get stuck. Write your own code."
|
||||
],
|
||||
"challengeSeed": [
|
||||
"function findLongestWord(str) {",
|
||||
" return str.length;",
|
||||
"}",
|
||||
"",
|
||||
"findLongestWord('The quick brown fox jumped over the lazy dog');"
|
||||
"findLongestWord(\"The quick brown fox jumped over the lazy dog\");"
|
||||
],
|
||||
"tests": [
|
||||
"assert(typeOf(findLongestWord(\"The quick brown fox jumped over the lazy dog\")) === 'number', '<code>findLongestWord()</code> should return a number.');",
|
||||
"assert(findLongestWord(\"The quick brown fox jumped over the lazy dog\") === 6, '\"The quick brown fox jumped over the lazy dog\" should return 6.');",
|
||||
"assert(findLongestWord(\"May the force be with you\") === 5, '\"May the force be with you\" should return 5.');",
|
||||
"assert(findLongestWord(\"Google do a barrel roll\") === 6, '\"Google do a barrel roll\" should return 6.');",
|
||||
"assert(findLongestWord(\"What is the average airspeed velocity of an unladen swallow\") === 8, '\"What is the average airspeed velocity of an unladen swallow\" should return 8.');",
|
||||
"assert(findLongestWord(\"What if we try a super-long word such as otorhinolaryngology\") === 19, '\"What if we try a super-long word such as otorhinolaryngology\" should return 18.');"
|
||||
"assert(typeOf(findLongestWord(\"The quick brown fox jumped over the lazy dog\")) === \"number\", '<code>findLongestWord()</code> should return a number.');",
|
||||
"assert(findLongestWord(\"The quick brown fox jumped over the lazy dog\") === 6, '<code>\"The quick brown fox jumped over the lazy dog\"</code> should return <code>6</code>.');",
|
||||
"assert(findLongestWord(\"May the force be with you\") === 5, '<code>\"May the force be with you\"</code> should return <code>5</code>.');",
|
||||
"assert(findLongestWord(\"Google do a barrel roll\") === 6, '<code>\"Google do a barrel roll\"</code> should return <code>6</code>.');",
|
||||
"assert(findLongestWord(\"What is the average airspeed velocity of an unladen swallow\") === 8, '<code>\"What is the average airspeed velocity of an unladen swallow\"</code> should return <code>8</code>.');",
|
||||
"assert(findLongestWord(\"What if we try a super-long word such as otorhinolaryngology\") === 19, '<code>\"What if we try a super-long word such as otorhinolaryngology\"</code> should return <code>18</code>.');"
|
||||
],
|
||||
"MDNlinks": [
|
||||
"String.split()",
|
||||
@ -218,21 +218,21 @@
|
||||
"difficulty": "1.05",
|
||||
"description": [
|
||||
"Return the provided string with the first letter of each word capitalized.",
|
||||
"For the purpose of this exercise, you should also capitalize connecting words like 'the' and 'of'.",
|
||||
"Remember to use <a href='//github.com/FreeCodeCamp/freecodecamp/wiki/How-to-get-help-when-you-get-stuck' target='_blank'>Read-Search-Ask</a> if you get stuck. Write your own code."
|
||||
"For the purpose of this exercise, you should also capitalize connecting words like \"the\" and \"of\".",
|
||||
"Remember to use <a href=\"//github.com/FreeCodeCamp/freecodecamp/wiki/How-to-get-help-when-you-get-stuck\" target=\"_blank\">Read-Search-Ask</a> if you get stuck. Write your own code."
|
||||
],
|
||||
"challengeSeed": [
|
||||
"function titleCase(str) {",
|
||||
" return str;",
|
||||
"}",
|
||||
"",
|
||||
"titleCase(\"I'm a little tea pot\", '');"
|
||||
"titleCase(\"I'm a little tea pot\", \"\");"
|
||||
],
|
||||
"tests": [
|
||||
"assert(typeOf(titleCase(\"I'm a little tea pot\")) === 'String', '<code>titleCase()</code> should return a string.');",
|
||||
"assert(titleCase(\"I'm a little tea pot\") === \"I'm A Little Tea Pot\", '\"I'm a little tea pot\" should return \"I'm A Little Tea Pot\"');",
|
||||
"assert(titleCase(\"sHoRt AnD sToUt\") === \"Short And Stout\", '\"sHoRt AnD sToUt\" should return \"Short And Stout\"');",
|
||||
"assert(titleCase(\"HERE IS MY HANDLE HERE IS MY SPOUT\") === \"Here Is My Handle Here Is My Spout\", '\"HERE IS MY HANDLE HERE IS MY SPOUT\" should return \"Here Is My Handle Here Is My Spout\"');"
|
||||
"assert(typeOf(titleCase(\"I'm a little tea pot\")) === \"String\", '<code>titleCase()</code> should return a string.');",
|
||||
"assert(titleCase(\"I'm a little tea pot\") === \"I'm A Little Tea Pot\", '<code>\"I'm a little tea pot\"</code> should return <code>\"I'm A Little Tea Pot\"</code>.');",
|
||||
"assert(titleCase(\"sHoRt AnD sToUt\") === \"Short And Stout\", '<code>\"sHoRt AnD sToUt\"</code> should return <code>\"Short And Stout\"</code>.');",
|
||||
"assert(titleCase(\"HERE IS MY HANDLE HERE IS MY SPOUT\") === \"Here Is My Handle Here Is My Spout\", '<code>\"HERE IS MY HANDLE HERE IS MY SPOUT\"</code> should return <code>\"Here Is My Handle Here Is My Spout\"</code>');"
|
||||
],
|
||||
"MDNlinks": [
|
||||
"String.charAt()"
|
||||
@ -258,7 +258,7 @@
|
||||
"Return an array consisting of the largest number from each provided sub-array. For simplicity, the provided array will contain exactly 4 sub-arrays.",
|
||||
"Remember, you can iterate through an array with a simple for loop, and access each member with array syntax arr[i] .",
|
||||
"If you are writing your own Chai.js tests, be sure to use a deep equal statement instead of an equal statement when comparing arrays.",
|
||||
"Remember to use <a href='//github.com/FreeCodeCamp/freecodecamp/wiki/How-to-get-help-when-you-get-stuck' target='_blank'>Read-Search-Ask</a> if you get stuck. Write your own code."
|
||||
"Remember to use <a href=\"//github.com/FreeCodeCamp/freecodecamp/wiki/How-to-get-help-when-you-get-stuck\" target=\"_blank\">Read-Search-Ask</a> if you get stuck. Write your own code."
|
||||
],
|
||||
"challengeSeed": [
|
||||
"function largestOfFour(arr) {",
|
||||
@ -266,12 +266,12 @@
|
||||
" return arr;",
|
||||
"}",
|
||||
"",
|
||||
"largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]], '');"
|
||||
"largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]], \"\");"
|
||||
],
|
||||
"tests": [
|
||||
"assert(typeOf(largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]])) === 'array', 'largestOfFour() should return an array.');",
|
||||
"(largestOfFour([[13, 27, 18, 26], [4, 5, 1, 3], [32, 35, 37, 39], [1000, 1001, 857, 1]]) === [27,5,39,1001], '<code>[[13, 27, 18, 26], [4, 5, 1, 3], [32, 35, 37, 39], [1000, 1001, 857, 1]] should return <code>[27,5,39,1001]</code>.');",
|
||||
"assert(largestOfFour([[4, 9, 1, 3], [13, 35, 18, 26], [32, 35, 97, 39], [1000000, 1001, 857, 1]]) === [9,35,97,1000000], '<code>[[4, 9, 1, 3], [13, 35, 18, 26], [32, 35, 97, 39], [1000000, 1001, 857, 1]]</code> should return <code>[9,35,97,1000000]</code>.');"
|
||||
"assert(typeOf(largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]])) === \"array\", '<code>largestOfFour()</code> should return an array.');",
|
||||
"(largestOfFour([[13, 27, 18, 26], [4, 5, 1, 3], [32, 35, 37, 39], [1000, 1001, 857, 1]]) === [27,5,39,1001], '<code>[[13, 27, 18, 26], [4, 5, 1, 3], [32, 35, 37, 39], [1000, 1001, 857, 1]]</code> should return <code>[27&344;5&344;39&344;1001]</code>.');",
|
||||
"assert(largestOfFour([[4, 9, 1, 3], [13, 35, 18, 26], [32, 35, 97, 39], [1000000, 1001, 857, 1]]) === [9,35,97,1000000], '<code>[[4&344; 9&344; 1&344; 3]&344; [13&344; 35&344; 18&344; 26]&344; [32&344; 35&344; 97&344; 39]&344; [1000000&344; 1001&344; 857&344; 1]]</code> should return <code>[9&344;35&344;97&344;1000000]</code>.');"
|
||||
],
|
||||
"MDNlinks": [
|
||||
"Comparison Operators"
|
||||
@ -295,7 +295,7 @@
|
||||
"difficulty": "1.07",
|
||||
"description": [
|
||||
"Check if a string (first argument) ends with the given target string (second argument).",
|
||||
"Remember to use <a href='//github.com/FreeCodeCamp/freecodecamp/wiki/How-to-get-help-when-you-get-stuck' target='_blank'>Read-Search-Ask</a> if you get stuck. Write your own code."
|
||||
"Remember to use <a href=\"//github.com/FreeCodeCamp/freecodecamp/wiki/How-to-get-help-when-you-get-stuck\" target=\"_blank\">Read-Search-Ask</a> if you get stuck. Write your own code."
|
||||
],
|
||||
"challengeSeed": [
|
||||
"function end(str, target) {",
|
||||
@ -304,14 +304,14 @@
|
||||
" return str;",
|
||||
"}",
|
||||
"",
|
||||
"end('Bastian', 'n', '');"
|
||||
"end(\"Bastian\", \"n\", \"\");"
|
||||
],
|
||||
"tests": [
|
||||
"assert(end('Bastian', 'n') === true, '<code>end(\"Bastian\", \"n\")</code> should return true.');",
|
||||
"assert(end('Connor', 'n') === false, '<code>end(\"Connor\", \"n\") </code> should return false.');",
|
||||
"assert(end('Walking on water and developing software from a specification are easy if both are frozen.', 'specification') === false, 'end(Walking on water and developing software from a specification are easy if both are frozen.', 'specification') should return false.');",
|
||||
"assert(end('He has to give me a new name', 'name') === true, '<code>end(\"He has to give me a new name\", \"name\")</code> should return true.');",
|
||||
"assert(end('If you want to save our world, you must hurry. We dont know how much longer we can withstand the nothing', 'mountain') === false, '<code>end('If you want to save our world, you must hurry. We dont know how much longer we can withstand the nothing', 'mountain')</code> should return false.');"
|
||||
"assert(end(\"Bastian\", \"n\") === true, '<code>end(\"Bastian\", \"n\")</code> should return true.');",
|
||||
"assert(end(\"Connor\", \"n\") === false, '<code>end(\"Connor\", \"n\") </code> should return false.');",
|
||||
"assert(end(\"Walking on water and developing software from a specification are easy if both are frozen.\", \"specification\") === false, '<code>Walking on water and developing software from a specification are easy if both are frozen.\", \"specification\")</code> should return false.');",
|
||||
"assert(end(\"He has to give me a new name\", \"name\") === true, '<code>\"He has to give me a new name\", \"name\"</code> should return true.');",
|
||||
"assert(end(\"If you want to save our world, you must hurry. We dont know how much longer we can withstand the nothing\", \"mountain\") === false, '<code>\"If you want to save our world, you must hurry. We dont know how much longer we can withstand the nothing\", \"mountain\"</code> should return false.');"
|
||||
],
|
||||
"MDNlinks": [
|
||||
"String.substr()"
|
||||
@ -335,7 +335,7 @@
|
||||
"difficulty": "1.08",
|
||||
"description": [
|
||||
"Repeat a given string (first argument) n times (second argument). Return an empty string if n is a negative number.",
|
||||
"Remember to use <a href='//github.com/FreeCodeCamp/freecodecamp/wiki/How-to-get-help-when-you-get-stuck' target='_blank'>Read-Search-Ask</a> if you get stuck. Write your own code."
|
||||
"Remember to use <a href=\"//github.com/FreeCodeCamp/freecodecamp/wiki/How-to-get-help-when-you-get-stuck\" target=\"_blank\">Read-Search-Ask</a> if you get stuck. Write your own code."
|
||||
],
|
||||
"challengeSeed": [
|
||||
"function repeat(str, num) {",
|
||||
@ -343,12 +343,12 @@
|
||||
" return str;",
|
||||
"}",
|
||||
"",
|
||||
"repeat('abc', 3, '');"
|
||||
"repeat(\"abc\", 3, \"\");"
|
||||
],
|
||||
"tests": [
|
||||
"assert(repeat('*', 3) === '***', '<code>repeat(\"*\", 3)</code> should return \"***\");",
|
||||
"assert(repeat('abc', 3) === 'abcabcabc', '<code>repeat(\"abc\", 3)</code> should return \"abcabcabc\".');",
|
||||
"assert(repeat('abc', -2) === '', '<code>repeat(\"abc\", -2)</code> should return \"\".');"
|
||||
"assert(repeat(\"*\", 3) === \"***\", '<code>\"*\", 3</code> should return <code>\"***\"</code>.);",
|
||||
"assert(repeat(\"abc\", 3) === \"abcabcabc\", '<code>\"abc\", 3</code> should return <code>\"abcabcabc\"</code>.');",
|
||||
"assert(repeat(\"abc\", -2) === \"\", '<code>\"abc\", -2</code> should return <code>\"\"</code>.');"
|
||||
],
|
||||
"MDNlinks": [
|
||||
"Global String Object"
|
||||
@ -371,9 +371,9 @@
|
||||
"title": "Truncate a string",
|
||||
"difficulty": "1.09",
|
||||
"description": [
|
||||
"Truncate a string (first argument) if it is longer than the given maximum string length (second argument). Return the truncated string with a '...' ending.",
|
||||
"Truncate a string (first argument) if it is longer than the given maximum string length (second argument). Return the truncated string with a \"...\" ending.",
|
||||
"Note that the three dots at the end add to the string length.",
|
||||
"Remember to use <a href='//github.com/FreeCodeCamp/freecodecamp/wiki/How-to-get-help-when-you-get-stuck' target='_blank'>Read-Search-Ask</a> if you get stuck. Write your own code."
|
||||
"Remember to use <a href=\"//github.com/FreeCodeCamp/freecodecamp/wiki/How-to-get-help-when-you-get-stuck\" target=\"_blank\">Read-Search-Ask</a> if you get stuck. Write your own code."
|
||||
],
|
||||
"challengeSeed": [
|
||||
"function truncate(str, num) {",
|
||||
@ -381,13 +381,13 @@
|
||||
" return str;",
|
||||
"}",
|
||||
"",
|
||||
"truncate('A-tisket a-tasket A green and yellow basket', 11, '');"
|
||||
"truncate(\"A-tisket a-tasket A green and yellow basket\", 11, \"\");"
|
||||
],
|
||||
"tests": [
|
||||
"assert(truncate('A-tisket a-tasket A green and yellow basket', 11) === 'A-tisket...', '<code>truncate(\"A-tisket a-tasket A green and yellow basket\", 11)</code> should return \"A-tisket...\".');",
|
||||
"assert(truncate('Peter Piper picked a peck of pickled peppers', 14) === 'Peter Piper...', '<code>truncate(\"Peter Piper picked a peck of pickled peppers\", 14)</code> should return \"Peter Piper...\".);",
|
||||
"assert(truncate('A-tisket a-tasket A green and yellow basket', 'A-tisket a-tasket A green and yellow basket'.length) === 'A-tisket a-tasket A green and yellow basket', <code>'truncate(\"A-tisket a-tasket A green and yellow basket\", \"A-tisket a-tasket A green and yellow basket\".length)</code> should return \"A-tisket a-tasket A green and yellow basket\".');",
|
||||
"assert(truncate('A-tisket a-tasket A green and yellow basket', 'A-tisket a-tasket A green and yellow basket'.length + 2 === 'A-tisket a-tasket A green and yellow basket', '<code>truncate(\"A-tisket a-tasket A green and yellow basket\", \"A-tisket a-tasket A green and yellow basket\".length + 2)</code> should return \"A-tisket a-tasket A green and yellow basket\".);"
|
||||
"assert(truncate(\"A-tisket a-tasket A green and yellow basket\", 11) === \"A-tisket...\", '<code>\"A-tisket a-tasket A green and yellow basket\", 1</code> should return <code>\"A-tisket...\"</code>.');",
|
||||
"assert(truncate(\"Peter Piper picked a peck of pickled peppers\", 14) === \"Peter Piper...\", '<code>\"Peter Piper picked a peck of pickled peppers\", 14</code> should return <code>\"Peter Piper...\"</code>.);",
|
||||
"assert(truncate(\"A-tisket a-tasket A green and yellow basket\", \"A-tisket a-tasket A green and yellow basket\".length) === \"A-tisket a-tasket A green and yellow basket\", '<code>\"A-tisket a-tasket A green and yellow basket\", \"A-tisket a-tasket A green and yellow basket\".length)</code> should return <code>\"A-tisket a-tasket A green and yellow basket\"</code>.');",
|
||||
"assert(truncate('A-tisket a-tasket A green and yellow basket', 'A-tisket a-tasket A green and yellow basket'.length + 2 === 'A-tisket a-tasket A green and yellow basket', '<code>\"A-tisket a-tasket A green and yellow basket\", \"A-tisket a-tasket A green and yellow basket\".length + 2</code> should return <code>\"A-tisket a-tasket A green and yellow basket\"</code>.);"
|
||||
],
|
||||
"MDNlinks": [
|
||||
"String.slice()"
|
||||
@ -411,7 +411,7 @@
|
||||
"difficulty": "1.10",
|
||||
"description": [
|
||||
"Write a function that splits an array (first argument) into groups the length of size (second argument) and returns them as a multidimensional array.",
|
||||
"Remember to use <a href='//github.com/FreeCodeCamp/freecodecamp/wiki/How-to-get-help-when-you-get-stuck' target='_blank'>Read-Search-Ask</a> if you get stuck. Write your own code."
|
||||
"Remember to use <a href=\"//github.com/FreeCodeCamp/freecodecamp/wiki/How-to-get-help-when-you-get-stuck\" target=\"_blank\">Read-Search-Ask</a> if you get stuck. Write your own code."
|
||||
],
|
||||
"challengeSeed": [
|
||||
"function chunk(arr, size) {",
|
||||
@ -419,13 +419,13 @@
|
||||
" return arr;",
|
||||
"}",
|
||||
"",
|
||||
"chunk(['a', 'b', 'c', 'd'], 2, '');"
|
||||
"chunk([\"a\", \"b\", \"c\", \"d\"], 2, \"\");"
|
||||
],
|
||||
"tests": [
|
||||
"assert(chunk(['a', 'b', 'c', 'd'], 2) === [['a', 'b'], ['c', 'd']], '<code>chunk([\"a\", \"b\", \"c\", \"d\"], 2)</code> should return <code>[[\"a\", \"b\"], [\"c\", \"d\"]]</code>.');",
|
||||
"assert(chunk([0, 1, 2, 3, 4, 5], 3) === [[0, 1, 2], [3, 4, 5]], '<code>chunk([0, 1, 2, 3, 4, 5]</code> should return <code>[[0, 1, 2], [3, 4, 5]]</code>.');",
|
||||
"assert(chunk([0, 1, 2, 3, 4, 5], 2) === [[0, 1], [2, 3], [4, 5]], '<code>chunk([0, 1, 2, 3, 4, 5], 2)</code> should return <code>[[0, 1], [2, 3], [4, 5]]</code>.');",
|
||||
"assert(chunk([0, 1, 2, 3, 4, 5], 4) === [[0, 1, 2, 3], [4, 5]], '<code>chunk([0, 1, 2, 3, 4, 5], 4)</code> should return <code>[[0, 1, 2, 3], [4, 5]]</code>.');"
|
||||
"assert(chunk([\"a\", \"b\", \"c\", \"d\"], 2) === [[\"a\", \"b\"], [\"c\", \"d\"]], '<code>[\"a\", \"b\", \"c\", \"d\"], 2</code> should return <code>[[\"a\", \"b\"], [\"c\", \"d\"]]</code>.');",
|
||||
"assert(chunk([0, 1, 2, 3, 4, 5], 3) === [[0, 1, 2], [3, 4, 5]], '<code>[0, 1, 2, 3, 4, 5]</code> should return <code>[[0, 1, 2], [3, 4, 5]]</code>.');",
|
||||
"assert(chunk([0, 1, 2, 3, 4, 5], 2) === [[0, 1], [2, 3], [4, 5]], '<code>[0, 1, 2, 3, 4, 5], 2</code> should return <code>[[0, 1], [2, 3], [4, 5]]</code>.');",
|
||||
"assert(chunk([0, 1, 2, 3, 4, 5], 4) === [[0, 1, 2, 3], [4, 5]], '<code>[0, 1, 2, 3, 4, 5], 4</code> should return <code>[[0, 1, 2, 3], [4, 5]]</code>.');"
|
||||
],
|
||||
"MDNlinks": [
|
||||
"Array.push()"
|
||||
@ -449,7 +449,7 @@
|
||||
"difficulty": "1.11",
|
||||
"description": [
|
||||
"Return the remaining elements of an array after chopping off n elements from the head.",
|
||||
"Remember to use <a href='//github.com/FreeCodeCamp/freecodecamp/wiki/How-to-get-help-when-you-get-stuck' target='_blank'>Read-Search-Ask</a> if you get stuck. Write your own code."
|
||||
"Remember to use <a href=\"//github.com/FreeCodeCamp/freecodecamp/wiki/How-to-get-help-when-you-get-stuck\" target=\"_blank\">Read-Search-Ask</a> if you get stuck. Write your own code."
|
||||
],
|
||||
"challengeSeed": [
|
||||
"function slasher(arr, howMany) {",
|
||||
@ -457,12 +457,12 @@
|
||||
" return arr;",
|
||||
"}",
|
||||
"",
|
||||
"slasher([1, 2, 3], 2, '');"
|
||||
"slasher([1, 2, 3], 2, \"\");"
|
||||
],
|
||||
"tests": [
|
||||
"assert(slasher([1, 2, 3], 2) === [3]), '<code>slasher([1, 2, 3], 2)</code>, [3] should return <code>[3]</code>.');",
|
||||
"assert(slasher([1, 2, 3], 0) === [1, 2, 3]), '<code>slasher([1, 2, 3], 0)</code> should return <code>[1, 2, 3]</code>.');",
|
||||
"assert(slasher([1, 2, 3], 9) === []), '<code>slasher([1, 2, 3], 9)</code> should return <code>[]</code>.');"
|
||||
"assert(slasher([1, 2, 3], 2) === [3]), '<code>[1, 2, 3], 2</code>, [3] should return <code>[3]</code>.');",
|
||||
"assert(slasher([1, 2, 3], 0) === [1, 2, 3]), '<code>[1, 2, 3], 0</code> should return <code>[1, 2, 3]</code>.');",
|
||||
"assert(slasher([1, 2, 3], 9) === []), '<code>[1, 2, 3], 9</code> should return <code>[]</code>.');"
|
||||
],
|
||||
"MDNlinks": [
|
||||
"Array.slice()",
|
||||
@ -487,27 +487,27 @@
|
||||
"difficulty": "1.12",
|
||||
"description": [
|
||||
"Return true if the string in the first element of the array contains all of the letters of the string in the second element of the array.",
|
||||
"For example, ['hello', 'Hello'], should return true because all of the letters in the second string are present in the first, ignoring case.",
|
||||
"The arguments ['hello', 'hey'] should return false because the string 'hello' does not contain a 'y'.",
|
||||
"Lastly, ['Alien', 'line'], should return true because all of the letters in 'line' are present in 'Alien'.",
|
||||
"Remember to use <a href='//github.com/FreeCodeCamp/freecodecamp/wiki/How-to-get-help-when-you-get-stuck' target='_blank'>Read-Search-Ask</a> if you get stuck. Write your own code."
|
||||
"For example, <code>[\"hello\", \"Hello\"]</code>, should return true because all of the letters in the second string are present in the first, ignoring case.",
|
||||
"The arguments <code>[\"hello\", \"hey\"]</code> should return false because the string \"hello\" does not contain a \"y\".",
|
||||
"Lastly, <code>[\"Alien\", \"line\"]</code>, should return true because all of the letters in \"line\" are present in \"Alien\".",
|
||||
"Remember to use <a href=\"//github.com/FreeCodeCamp/freecodecamp/wiki/How-to-get-help-when-you-get-stuck\" target=\"_blank\">Read-Search-Ask</a> if you get stuck. Write your own code."
|
||||
],
|
||||
"challengeSeed": [
|
||||
"function mutation(arr) {",
|
||||
" return arr;",
|
||||
"}",
|
||||
"",
|
||||
"mutation(['hello', 'hey'], '');"
|
||||
"mutation([\"hello\", \"hey\"], \"\");"
|
||||
],
|
||||
"tests": [
|
||||
"assert(mutation(['hello', 'hey'])).to.be.false;",
|
||||
"assert(mutation(['hello', 'Hello'])).to.be.true;",
|
||||
"assert(mutation(['zyxwvutsrqponmlkjihgfedcba', 'qrstu'])).to.be.true;",
|
||||
"assert(mutation(['Mary', 'Army'])).to.be.true;",
|
||||
"assert(mutation(['Mary', 'Aarmy'])).to.be.true;",
|
||||
"assert(mutation(['Alien', 'line'])).to.be.true;",
|
||||
"assert(mutation(['floor', 'for'])).to.be.true;",
|
||||
"assert(mutation(['hello', 'neo'])).to.be.false;"
|
||||
"assert(mutation([\"hello\", \"hey\"]) === false, '<code>[\"hello\"&344; \"hey\"]</code> should return false.');",
|
||||
"assert(mutation([\"hello\", \"Hello\"]) === true, '<code>[\"hello\"&344; \"Hello\"]</code> should return true.');",
|
||||
"assert(mutation([\"zyxwvutsrqponmlkjihgfedcba\", \"qrstu\"]) === true, '<code>[\"zyxwvutsrqponmlkjihgfedcba\"&344; \"qrstu\"]</code> should return true.');",
|
||||
"assert(mutation([\"Mary\", \"Army\"]) === true, '<code>[\"Mary\"&344; \"Army\"]</code> should return true.');",
|
||||
"assert(mutation([\"Mary\", \"Aarmy\"]) === true, '<code>[\"Mary\"&344; \"Aarmy\"]</code> should return true.');",
|
||||
"assert(mutation([\"Alien\", \"line\"]) === true, '<code>[\"Alien\"&344; \"line\"]</code> should return true.');",
|
||||
"assert(mutation([\"floor\", \"for\"]) === true, '<code>[\"floor\"&344; \"for\"]</code> should return true.');",
|
||||
"assert(mutation([\"hello\", \"neo\"]) === false, '<code>[\"hello\"&344; \"neo\"]</code> should return false.');"
|
||||
],
|
||||
"MDNlinks": [
|
||||
"Array.indexOf()"
|
||||
@ -532,7 +532,7 @@
|
||||
"description": [
|
||||
"Remove all falsey values from an array.",
|
||||
"Falsey values in javascript are false, null, 0, \"\", undefined, and NaN.",
|
||||
"Remember to use <a href='//github.com/FreeCodeCamp/freecodecamp/wiki/How-to-get-help-when-you-get-stuck' target='_blank'>Read-Search-Ask</a> if you get stuck. Write your own code."
|
||||
"Remember to use <a href=\"//github.com/FreeCodeCamp/freecodecamp/wiki/How-to-get-help-when-you-get-stuck\" target=\"_blank\">Read-Search-Ask</a> if you get stuck. Write your own code."
|
||||
],
|
||||
"challengeSeed": [
|
||||
"function bouncer(arr) {",
|
||||
@ -540,12 +540,12 @@
|
||||
" return arr;",
|
||||
"}",
|
||||
"",
|
||||
"bouncer([7, 'ate', '', false, 9], '');"
|
||||
"bouncer([7, \"ate\", \"\", false, 9], \"\");"
|
||||
],
|
||||
"tests": [
|
||||
"assert.deepEqual(bouncer([7, 'ate', '', false, 9]), [7, 'ate', 9], 'should remove falsey values', '');",
|
||||
"assert.deepEqual(bouncer(['a', 'b', 'c']), ['a', 'b', 'c'], 'should return full array if no falsey elements', '');",
|
||||
"assert.deepEqual(bouncer([false, null, 0]), [], 'should return empty array if all elements are falsey', '');"
|
||||
"assert(bouncer([7, \"ate\", \"\", false, 9]) === [7, \"ate\", 9], '<code>[7&344; \"ate\"&344; \"\"&344; false&344; 9]</code> should return <code>[7&344; \"ate\"&344; 9]</code>.');",
|
||||
"assert(bouncer([\"a\", \"b\", \"c\"]) === [\"a\", \"b\", \"c\"], '<code>[\"a\"&344; \"b\"&344; \"c\"]</code> should return <code>[\"a\"&344; \"b\"&344; \"c\"]</code>.');",
|
||||
"assert(bouncer([false, null, 0]) === [], '<code>[false&344; null&344; 0]</code> should return <code>[]</code>.');"
|
||||
],
|
||||
"MDNlinks": [
|
||||
"Boolean Objects",
|
||||
@ -570,7 +570,7 @@
|
||||
"difficulty": "1.55",
|
||||
"description": [
|
||||
"Make a function that looks through an array (first argument) and returns an array of all objects that have equivalent property values (second argument).",
|
||||
"Remember to use <a href='//github.com/FreeCodeCamp/freecodecamp/wiki/How-to-get-help-when-you-get-stuck' target='_blank'>Read-Search-Ask</a> if you get stuck. Write your own code."
|
||||
"Remember to use <a href=\"//github.com/FreeCodeCamp/freecodecamp/wiki/How-to-get-help-when-you-get-stuck\" target=\"_blank\">Read-Search-Ask</a> if you get stuck. Write your own code."
|
||||
],
|
||||
"challengeSeed": [
|
||||
"function where(collection, source) {",
|
||||
@ -579,11 +579,11 @@
|
||||
" return arr;",
|
||||
"}",
|
||||
"",
|
||||
"where([{ first: 'Romeo', last: 'Montague' }, { first: 'Mercutio', last: null }, { first: 'Tybalt', last: 'Capulet' }], { last: 'Capulet' }, '');"
|
||||
"where([{ first: \"Romeo\", last: \"Montague\" }, { first: \"Mercutio\", last: null }, { first: \"Tybalt\", last: \"Capulet\" }], { last: \"Capulet\" }, \"\");"
|
||||
],
|
||||
"tests": [
|
||||
"assert.deepEqual(where([{ first: 'Romeo', last: 'Montague' }, { first: 'Mercutio', last: null }, { first: 'Tybalt', last: 'Capulet' }], { last: 'Capulet' }), [{ first: 'Tybalt', last: 'Capulet' }], 'should return an array of objects', '');",
|
||||
"assert.deepEqual(where([{ 'a': 1 }, { 'a': 1 }, { 'a': 1, 'b': 2 }], { 'a': 1 }), [{ 'a': 1 }, { 'a': 1 }, { 'a': 1, 'b': 2 }], 'should return with multiples', '');"
|
||||
"assert(where([{ first: \"Romeo\", last: \"Montague\" }, { first: \"Mercutio\", last: null }, { first: \"Tybalt\", last: \"Capulet\" }], { last: \"Capulet\" }) === [{ first: \"Tybalt\", last: \"Capulet\" }], '<code>[{ first: \"Romeo\"&344; last: \"Montague\" }&344; { first: \"Mercutio\"&344; last: null }&344; { first: \"Tybalt\"&344; last: \"Capulet\" }]&344; { last: \"Capulet\" }</code> should return <code>[{ first: \"Tybalt\"&344; last: \"Capulet\" }]</code>.');",
|
||||
"assert(where([{ \"a\": 1 }, { \"a\": 1 }, { \"a\": 1, \"b\": 2 }], { \"a\": 1 }) === [{ \"a\": 1 }, { \"a\": 1 }, { \"a\": 1, \"b\": 2 }], '<code>[{ \"a\": 1 }&344; { \"a\": 1 }&344; { \"a\": 1&344; \"b\": 2 }]&344; { \"a\": 1 }</code> should return <code>[{ \"a\": 1 }&344; { \"a\": 1 }&344; { \"a\": 1&344; \"b\": 2 }]</code>.');"
|
||||
],
|
||||
"MDNlinks": [
|
||||
"Global Object",
|
||||
@ -609,7 +609,7 @@
|
||||
"difficulty": "1.60",
|
||||
"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.",
|
||||
"Remember to use <a href='//github.com/FreeCodeCamp/freecodecamp/wiki/How-to-get-help-when-you-get-stuck' target='_blank'>Read-Search-Ask</a> if you get stuck. Write your own code."
|
||||
"Remember to use <a href=\"//github.com/FreeCodeCamp/freecodecamp/wiki/How-to-get-help-when-you-get-stuck\" target=\"_blank\">Read-Search-Ask</a> if you get stuck. Write your own code."
|
||||
],
|
||||
"challengeSeed": [
|
||||
"function destroyer(arr) {",
|
||||
@ -617,14 +617,14 @@
|
||||
" return arr;",
|
||||
"}",
|
||||
"",
|
||||
"destroyer([1, 2, 3, 1, 2, 3], 2, 3, '');"
|
||||
"destroyer([1, 2, 3, 1, 2, 3], 2, 3, \"\");"
|
||||
],
|
||||
"tests": [
|
||||
"assert.deepEqual(destroyer([1, 2, 3, 1, 2, 3], 2, 3), [1, 1], 'should remove correct values from an array', '');",
|
||||
"assert.deepEqual(destroyer([1, 2, 3, 5, 1, 2, 3], 2, 3), [1, 5, 1], 'should remove correct values from an array', '');",
|
||||
"assert.deepEqual(destroyer([3, 5, 1, 2, 2], 2, 3, 5), [1], 'should accept more than two additional arguments', '');",
|
||||
"assert.deepEqual(destroyer([2, 3, 2, 3], 2, 3), [], 'should remove correct values from an array', '');",
|
||||
"assert.deepEqual(destroyer(['tree', 'hamburger', 53], 'tree', 53), ['hamburger'], 'should handle NaN-elements', '');"
|
||||
"assert(destroyer([1, 2, 3, 1, 2, 3], 2, 3) === [1, 1], '<code>[1&344; 2&344; 3&344; 1&344; 2&344; 3]&344; 2&344; 3</code> should return <code>[1&344; 1]</code>');",
|
||||
"assert(destroyer([1, 2, 3, 5, 1, 2, 3], 2, 3) === [1, 5, 1], '<code>[1, 2, 3, 5, 1, 2, 3], 2, 3</code> should return <code>[1, 5, 1]</code>.');",
|
||||
"assert(destroyer([3, 5, 1, 2, 2], 2, 3, 5) === [1], '<code>[3, 5, 1, 2, 2], 2, 3, 5</code> should return <code>[1]</code>.');",
|
||||
"assert(destroyer([2, 3, 2, 3], 2, 3) === [], '<code>[2, 3, 2, 3], 2, 3</code> should return <code>[]</code>.');",
|
||||
"assert(destroyer([\"tree\", \"hamburger\", 53], \"tree\", 53) === [\"hamburger\"], '<code>[\"tree\", \"hamburger\", 53], \"tree\", 53)</code> should return <code>[\"hamburger\"]</code>.');"
|
||||
],
|
||||
"MDNlinks": [
|
||||
"Arguments object",
|
||||
@ -650,7 +650,7 @@
|
||||
"description": [
|
||||
"Return the lowest index at which a value (second argument) should be inserted into a sorted array (first argument).",
|
||||
"For example, where([1,2,3,4], 1.5) should return 1 because it is greater than 1 (0th index), but less than 2 (1st index).",
|
||||
"Remember to use <a href='//github.com/FreeCodeCamp/freecodecamp/wiki/How-to-get-help-when-you-get-stuck' target='_blank'>Read-Search-Ask</a> if you get stuck. Write your own code."
|
||||
"Remember to use <a href=\"//github.com/FreeCodeCamp/freecodecamp/wiki/How-to-get-help-when-you-get-stuck\" target=\"_blank\">Read-Search-Ask</a> if you get stuck. Write your own code."
|
||||
],
|
||||
"challengeSeed": [
|
||||
"function where(arr, num) {",
|
||||
@ -658,14 +658,14 @@
|
||||
" return num;",
|
||||
"}",
|
||||
"",
|
||||
"where([40, 60], 50, '');"
|
||||
"where([40, 60], 50, \"\");"
|
||||
],
|
||||
"MDNlinks": [
|
||||
"Array.sort()"
|
||||
],
|
||||
"tests": [
|
||||
"assert(where([10, 20, 30, 40, 50], 35) === 3, '');",
|
||||
"assert(where([10, 20, 30, 40, 50], 30) === 2, '');"
|
||||
"assert(where([10, 20, 30, 40, 50], 35) === 3, '<code>[10, 20, 30, 40, 50], 35</code> should return <code>3</code>.');",
|
||||
"assert(where([10, 20, 30, 40, 50], 30) === 2, '<code>[10, 20, 30, 40, 50], 30)</code> should return <code>2</code>.');"
|
||||
],
|
||||
"type": "bonfire",
|
||||
"challengeType": 5,
|
||||
|
Reference in New Issue
Block a user