Files
freeCodeCamp/seed/challenges/basic-bonfires.json

654 lines
31 KiB
JSON
Raw Normal View History

{
"name": "Basic Algorithm Scripting",
"order": 0.007,
"challenges": [
{
2015-06-09 13:30:57 -07:00
"id": "ad7123c8c441eddfaeb5bdef",
2015-08-07 23:37:32 -07:00
"title": "Meet Bonfire",
"difficulty": "0",
"description": [
"Your goal is to fix the failing test.",
"First, run all the tests by clicking \"Run tests\" or by pressing Control + Enter.",
"The failing test is in red. Fix the code so that all tests pass. Then you can move on to the next Bonfire.",
"Make this function return true no matter what."
],
"tests": [
"assert(typeof(meetBonfire()) === \"boolean\", 'message: The result should be a Boolean value of true or false.');",
"assert(meetBonfire() === true, 'message: Your <code>meetBonfire()</code> function should return <code>true</code>.');"
],
"challengeSeed": [
"function meetBonfire(argument) {",
" // Good luck!",
" console.log(\"you can read this function's argument in the developer tools\", argument);",
"",
" return false;",
"}",
"",
"",
"",
"meetBonfire(\"You can do this!\");"
2015-05-20 11:13:55 -04:00
],
2015-08-07 23:37:32 -07:00
"type": "bonfire",
"challengeType": 5,
"nameCn": "",
"descriptionCn": [],
"nameFr": "",
"descriptionFr": [],
"nameRu": "",
"descriptionRu": [],
"nameEs": "",
"descriptionEs": [],
"namePt": "",
"descriptionPt": []
},
{
2015-06-09 13:30:57 -07:00
"id": "a202eed8fc186c8434cb6d61",
2015-08-07 23:37:32 -07:00
"title": "Reverse a String",
"difficulty": "1.01",
"tests": [
"assert(typeof(reverseString(\"hello\")) === \"string\", 'message: <code>reverseString&#40;&#41;</code> should return a string.');",
"assert(reverseString(\"hello\") === \"olleh\", 'message: <code>\"hello\"</code> should become <code>\"olleh\"</code>.');",
"assert(reverseString(\"Howdy\") === \"ydwoH\", 'message: <code>\"Howdy\"</code> should become <code>\"ydwoH\"</code>.');",
"assert(reverseString(\"Greetings from Earth\") === \"htraE morf sgniteerG\", 'message: <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.",
2015-08-26 23:23:46 -07:00
"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;",
"}",
"",
2015-08-26 23:23:46 -07:00
"reverseString(\"hello\", \"\");"
],
"MDNlinks": [
"Global String Object",
"String.split()",
"Array.reverse()",
"Array.join()"
],
2015-08-07 23:37:32 -07:00
"type": "bonfire",
"challengeType": 5,
"nameCn": "",
"descriptionCn": [],
"nameFr": "",
"descriptionFr": [],
"nameRu": "",
"descriptionRu": [],
"nameEs": "",
"descriptionEs": [],
"namePt": "",
"descriptionPt": []
},
{
2015-06-09 13:30:57 -07:00
"id": "a302f7aae1aa3152a5b413bc",
2015-08-07 23:37:32 -07:00
"title": "Factorialize a Number",
"tests": [
"assert(typeof(factorialize(5)) === \"number\", 'message: <code>factorialize&#40;&#41;</code> should return a number.');",
"assert(factorialize(5) === 120, 'message: <code>5</code> should return <code>120</code>.');",
"assert(factorialize(10) === 3628800, 'message: <code>10</code> should return <code>3,628,800</code>.');",
"assert(factorialize(20) === 2432902008176640000, 'message: <code>20</code> should return <code>2,432,902,008,176,640,000</code>.');",
"assert(factorialize(0) === 1, 'message: <code>0</code> should return 1.');"
],
"difficulty": "1.02",
"description": [
"Return the factorial of the provided integer.",
"If the integer is represented with the letter n, a factorial is the product of all positive integers less than or equal to n.",
2015-08-23 15:18:40 -07:00
"Factorials are often represented with the shorthand notation <code>n!</code>",
"For example: <code>5! = 1 * 2 * 3 * 4 * 5 = 120</code>",
2015-08-26 23:23:46 -07:00
"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) {",
" return num;",
"}",
"",
2015-08-23 13:10:30 -07:00
"factorialize(5, '');"
],
"MDNlinks": [
"Arithmetic Operators"
],
2015-08-07 23:37:32 -07:00
"type": "bonfire",
"challengeType": 5,
"nameCn": "",
"descriptionCn": [],
"nameFr": "",
"descriptionFr": [],
"nameRu": "",
"descriptionRu": [],
"nameEs": "",
"descriptionEs": [],
"namePt": "",
"descriptionPt": []
},
{
2015-06-09 13:30:57 -07:00
"id": "aaa48de84e1ecc7c742e1124",
2015-08-07 23:37:32 -07:00
"title": "Check for Palindromes",
"difficulty": "1.03",
"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.",
"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.",
2015-08-26 23:23:46 -07:00
"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\", 'message: <code>palindrome&#40;&#41;<code> should return a boolean.');",
"assert(palindrome(\"eye\") === true, 'message: <code>\"eye\"</code> should return true.');",
"assert(palindrome(\"race car\") === true, 'message: <code>\"race car\"</code> should return true.');",
"assert(palindrome(\"not a palindrome\") === false, 'message: <code>\"not a palindrome\"</code> should return false.');",
"assert(palindrome(\"A man, a plan, a canal. Panama\") === true, 'message: <code>\"A man, a plan, a canal. Panama\"</code> should return true.');",
"assert(palindrome(\"never odd or even\") === true, 'message: <code>\"never odd or even\"</code> should return true.');",
"assert(palindrome(\"nope\") === false, 'message: <code>\"nope\"</code> should return false.');",
"assert(palindrome(\"almostomla\") === false, 'message: <code>\"almostomla\"</code> should return false.');",
"assert(palindrome(\"My age is 0, 0 si ega ym.\") === true, 'message: <code>\"My age is 0, 0 si ega ym.\"</code> should return true.');",
"assert(palindrome(\"1 eye for of 1 eye.\") === false, 'message: <code>\"1 eye for of 1 eye.\"</code> should return false.');",
"assert(palindrome(\"0_0 (: /-\\ :) 0-0\") === true, 'message: <code>\"0_0 (: /-\\\\ :) 0-0\"</code> should return true.');"
],
"challengeSeed": [
"function palindrome(str) {",
" // Good luck!",
" return true;",
"}",
"",
"",
"",
"palindrome(\"eye\");"
],
"MDNlinks": [
"String.replace()",
"String.toLowerCase()"
],
2015-08-07 23:37:32 -07:00
"type": "bonfire",
"challengeType": 5,
"nameCn": "",
"descriptionCn": [],
"nameFr": "",
"descriptionFr": [],
"nameRu": "",
"descriptionRu": [],
"nameEs": "",
"descriptionEs": [],
"namePt": "",
"descriptionPt": []
},
{
2015-06-09 13:30:57 -07:00
"id": "a26cbbe9ad8655a977e1ceb5",
2015-08-07 23:37:32 -07:00
"title": "Find the Longest Word in a String",
"difficulty": "1.04",
"description": [
"Return the length of the longest word in the provided sentence.",
"Your response should be a number.",
2015-08-26 23:23:46 -07:00
"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;",
"}",
"",
2015-08-26 23:23:46 -07:00
"findLongestWord(\"The quick brown fox jumped over the lazy dog\");"
],
"tests": [
"assert(typeof(findLongestWord(\"The quick brown fox jumped over the lazy dog\")) === \"number\", 'message: <code>findLongestWord&#40;&#41;</code> should return a number.');",
"assert(findLongestWord(\"The quick brown fox jumped over the lazy dog\") === 6, 'message: <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, 'message: <code>\"May the force be with you\"</code> should return <code>5</code>.');",
"assert(findLongestWord(\"Google do a barrel roll\") === 6, 'message: <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, 'message: <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, 'message: <code>\"What if we try a super-long word such as otorhinolaryngology\"</code> should return <code>19</code>.');"
],
"MDNlinks": [
"String.split()",
"String.length"
],
2015-08-07 23:37:32 -07:00
"type": "bonfire",
"challengeType": 5,
"nameCn": "",
"descriptionCn": [],
"nameFr": "",
"descriptionFr": [],
"nameRu": "",
"descriptionRu": [],
"nameEs": "",
"descriptionEs": [],
"namePt": "",
"descriptionPt": []
},
{
2015-06-09 13:30:57 -07:00
"id": "ab6137d4e35944e21037b769",
2015-08-07 23:37:32 -07:00
"title": "Title Case a Sentence",
"difficulty": "1.05",
"description": [
2015-09-14 14:30:53 -07:00
"Return the provided string with the first letter of each word capitalized. Make sure the rest of the word is in lower case.",
2015-08-26 23:23:46 -07:00
"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;",
"}",
"",
2015-08-26 23:23:46 -07:00
"titleCase(\"I'm a little tea pot\", \"\");"
],
"tests": [
"assert(typeof(titleCase(\"I&#39;m a little tea pot\")) === \"string\", 'message: <code>titleCase&#40;&#41;</code> should return a string.');",
"assert(titleCase(\"I&#39;m a little tea pot\") === \"I&#39;m A Little Tea Pot\", 'message: <code>\"I&#39;m a little tea pot\"</code> should return <code>\"I&#39;m A Little Tea Pot\"</code>.');",
"assert(titleCase(\"sHoRt AnD sToUt\") === \"Short And Stout\", 'message: <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\", 'message: <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()"
],
2015-08-07 23:37:32 -07:00
"type": "bonfire",
"challengeType": 5,
"nameCn": "",
"descriptionCn": [],
"nameFr": "",
"descriptionFr": [],
"nameRu": "",
"descriptionRu": [],
"nameEs": "",
"descriptionEs": [],
"namePt": "",
"descriptionPt": []
},
{
2015-06-09 13:30:57 -07:00
"id": "a789b3483989747d63b0e427",
2015-08-07 23:37:32 -07:00
"title": "Return Largest Numbers in Arrays",
"difficulty": "1.06",
"description": [
"Return an array consisting of the largest number from each provided sub-array. For simplicity, the provided array will contain exactly 4 sub-arrays.",
"Remember, you can iterate through an array with a simple for loop, and access each member with array syntax arr[i] .",
"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.",
2015-08-26 23:23:46 -07:00
"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) {",
" // You can do this!",
" return arr;",
"}",
"",
"largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);"
],
"tests": [
"assert(largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]).constructor === Array, 'message: <code>largestOfFour&#40;&#41;</code> should return an array.');",
"assert.deepEqual(largestOfFour([[13, 27, 18, 26], [4, 5, 1, 3], [32, 35, 37, 39], [1000, 1001, 857, 1]]), [27,5,39,1001], 'message: <code>[[13, 27, 18, 26], [4, 5, 1, 3], [32, 35, 37, 39], [1000, 1001, 857, 1]]</code> should return <code>[27,5,39,1001]</code>.');",
"assert.deepEqual(largestOfFour([[4, 9, 1, 3], [13, 35, 18, 26], [32, 35, 97, 39], [1000000, 1001, 857, 1]]), [9,35,97,1000000], 'message: <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>.');"
],
"MDNlinks": [
"Comparison Operators"
],
2015-08-07 23:37:32 -07:00
"type": "bonfire",
"challengeType": 5,
"nameCn": "",
"descriptionCn": [],
"nameFr": "",
"descriptionFr": [],
"nameRu": "",
"descriptionRu": [],
"nameEs": "",
"descriptionEs": [],
"namePt": "",
"descriptionPt": []
},
{
2015-06-09 13:30:57 -07:00
"id": "acda2fb1324d9b0fa741e6b5",
2015-08-07 23:37:32 -07:00
"title": "Confirm the Ending",
"difficulty": "1.07",
"description": [
"Check if a string (first argument) ends with the given target string (second argument).",
2015-08-26 23:23:46 -07:00
"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) {",
" // \"Never give up and good luck will find you.\"",
" // -- Falcor",
" return str;",
"}",
"",
2015-08-26 23:23:46 -07:00
"end(\"Bastian\", \"n\", \"\");"
],
"tests": [
"assert(end(\"Bastian\", \"n\") === true, 'message: <code>\"Bastian\", \"n\"</code> should return true.');",
"assert(end(\"Connor\", \"n\") === false, 'message: <code>\"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, 'message: <code>\"Walking on water and developing software from a specification are easy if both are frozen.\", \"specification\"&#41;</code> should return false.');",
"assert(end(\"He has to give me a new name\", \"name\") === true, 'message: <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, 'message: <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()"
],
2015-08-07 23:37:32 -07:00
"type": "bonfire",
"challengeType": 5,
"nameCn": "",
"descriptionCn": [],
"nameFr": "",
"descriptionFr": [],
"nameRu": "",
"descriptionRu": [],
"nameEs": "",
"descriptionEs": [],
"namePt": "",
"descriptionPt": []
},
{
2015-06-09 13:30:57 -07:00
"id": "afcc8d540bea9ea2669306b6",
2015-08-07 23:37:32 -07:00
"title": "Repeat a string repeat a string",
"difficulty": "1.08",
"description": [
"Repeat a given string (first argument) n times (second argument). Return an empty string if n is a negative number.",
2015-08-26 23:23:46 -07:00
"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) {",
" // repeat after me",
" return str;",
"}",
"",
2015-08-26 23:23:46 -07:00
"repeat(\"abc\", 3, \"\");"
],
"tests": [
"assert(repeat(\"*\", 3) === \"***\", 'message: <code>\"*\", 3</code> should return <code>\"***\"</code>.');",
"assert(repeat(\"abc\", 3) === \"abcabcabc\", 'message: <code>\"abc\", 3</code> should return <code>\"abcabcabc\"</code>.');",
"assert(repeat(\"abc\", -2) === \"\", 'message: <code>\"abc\", -2</code> should return <code>\"\"</code>.');"
],
"MDNlinks": [
"Global String Object"
],
2015-08-07 23:37:32 -07:00
"type": "bonfire",
"challengeType": 5,
"nameCn": "",
"descriptionCn": [],
"nameFr": "",
"descriptionFr": [],
"nameRu": "",
"descriptionRu": [],
"nameEs": "",
"descriptionEs": [],
"namePt": "",
"descriptionPt": []
},
{
2015-06-09 13:30:57 -07:00
"id": "ac6993d51946422351508a41",
2015-08-07 23:37:32 -07:00
"title": "Truncate a string",
"difficulty": "1.09",
"description": [
2015-08-26 23:23:46 -07:00
"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.",
2015-08-26 23:23:46 -07:00
"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) {",
" // Clear out that junk in your trunk",
" return str;",
"}",
"",
2015-08-26 23:23:46 -07:00
"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...\", 'message: <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...\", 'message: <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\", 'message: <code>\"A-tisket a-tasket A green and yellow basket\", \"A-tisket a-tasket A green and yellow basket\".length&#41;</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', 'message: <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()"
],
2015-08-07 23:37:32 -07:00
"type": "bonfire",
"challengeType": 5,
"nameCn": "",
"descriptionCn": [],
"nameFr": "",
"descriptionFr": [],
"nameRu": "",
"descriptionRu": [],
"nameEs": "",
"descriptionEs": [],
"namePt": "",
"descriptionPt": []
},
{
2015-06-09 13:30:57 -07:00
"id": "a9bd25c716030ec90084d8a1",
2015-08-07 23:37:32 -07:00
"title": "Chunky Monkey",
"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.",
2015-08-26 23:23:46 -07:00
"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) {",
" // Break it up.",
" return arr;",
"}",
"",
2015-08-26 23:23:46 -07:00
"chunk([\"a\", \"b\", \"c\", \"d\"], 2, \"\");"
],
"tests": [
"assert.deepEqual(chunk([\"a\", \"b\", \"c\", \"d\"], 2), [[\"a\", \"b\"], [\"c\", \"d\"]], 'message: <code>[\"a\", \"b\", \"c\", \"d\"], 2</code> should return <code>[[\"a\", \"b\"], [\"c\", \"d\"]]</code>.');",
"assert.deepEqual(chunk([0, 1, 2, 3, 4, 5], 3), [[0, 1, 2], [3, 4, 5]], 'message: <code>[0, 1, 2, 3, 4, 5]</code> should return <code>[[0, 1, 2], [3, 4, 5]]</code>.');",
"assert.deepEqual(chunk([0, 1, 2, 3, 4, 5], 2), [[0, 1], [2, 3], [4, 5]], 'message: <code>[0, 1, 2, 3, 4, 5], 2</code> should return <code>[[0, 1], [2, 3], [4, 5]]</code>.');",
"assert.deepEqual(chunk([0, 1, 2, 3, 4, 5], 4), [[0, 1, 2, 3], [4, 5]], 'message: <code>[0, 1, 2, 3, 4, 5], 4</code> should return <code>[[0, 1, 2, 3], [4, 5]]</code>.');"
],
"MDNlinks": [
"Array.push()"
],
2015-08-07 23:37:32 -07:00
"type": "bonfire",
"challengeType": 5,
"nameCn": "",
"descriptionCn": [],
"nameFr": "",
"descriptionFr": [],
"nameRu": "",
"descriptionRu": [],
"nameEs": "",
"descriptionEs": [],
"namePt": "",
"descriptionPt": []
},
{
2015-06-09 13:30:57 -07:00
"id": "ab31c21b530c0dafa9e241ee",
2015-08-07 23:37:32 -07:00
"title": "Slasher Flick",
"difficulty": "1.11",
"description": [
"Return the remaining elements of an array after chopping off n elements from the head.",
2015-08-26 23:23:46 -07:00
"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) {",
" // it doesn't always pay to be first",
" return arr;",
"}",
"",
2015-08-26 23:23:46 -07:00
"slasher([1, 2, 3], 2, \"\");"
],
"tests": [
"assert.deepEqual(slasher([1, 2, 3], 2), [3], 'message: <code>[1, 2, 3], 2, [3]</code> should return <code>[3]</code>.');",
"assert.deepEqual(slasher([1, 2, 3], 0), [1, 2, 3], 'message: <code>[1, 2, 3], 0</code> should return <code>[1, 2, 3]</code>.');",
"assert.deepEqual(slasher([1, 2, 3], 9), [], 'message: <code>[1, 2, 3], 9</code> should return <code>[]</code>.');"
],
"MDNlinks": [
"Array.slice()",
"Array.splice()"
],
2015-08-07 23:37:32 -07:00
"type": "bonfire",
"challengeType": 5,
"nameCn": "",
"descriptionCn": [],
"nameFr": "",
"descriptionFr": [],
"nameRu": "",
"descriptionRu": [],
"nameEs": "",
"descriptionEs": [],
"namePt": "",
"descriptionPt": []
},
{
2015-06-09 13:30:57 -07:00
"id": "af2170cad53daa0770fabdea",
2015-08-07 23:37:32 -07:00
"title": "Mutations",
"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.",
2015-08-26 23:23:46 -07:00
"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;",
"}",
"",
2015-08-26 23:23:46 -07:00
"mutation([\"hello\", \"hey\"], \"\");"
],
"tests": [
"assert(mutation([\"hello\", \"hey\"]) === false, 'message: <code>[\"hello\", \"hey\"]</code> should return false.');",
"assert(mutation([\"hello\", \"Hello\"]) === true, 'message: <code>[\"hello\", \"Hello\"]</code> should return true.');",
"assert(mutation([\"zyxwvutsrqponmlkjihgfedcba\", \"qrstu\"]) === true, 'message: <code>[\"zyxwvutsrqponmlkjihgfedcba\", \"qrstu\"]</code> should return true.');",
"assert(mutation([\"Mary\", \"Army\"]) === true, 'message: <code>[\"Mary\", \"Army\"]</code> should return true.');",
"assert(mutation([\"Mary\", \"Aarmy\"]) === true, 'message: <code>[\"Mary\", \"Aarmy\"]</code> should return true.');",
"assert(mutation([\"Alien\", \"line\"]) === true, 'message: <code>[\"Alien\", \"line\"]</code> should return true.');",
"assert(mutation([\"floor\", \"for\"]) === true, 'message: <code>[\"floor\", \"for\"]</code> should return true.');",
"assert(mutation([\"hello\", \"neo\"]) === false, 'message: <code>[\"hello\", \"neo\"]</code> should return false.');"
],
"MDNlinks": [
2015-05-31 14:08:44 -07:00
"Array.indexOf()"
],
2015-08-07 23:37:32 -07:00
"type": "bonfire",
"challengeType": 5,
"nameCn": "",
"descriptionCn": [],
"nameFr": "",
"descriptionFr": [],
"nameRu": "",
"descriptionRu": [],
"nameEs": "",
"descriptionEs": [],
"namePt": "",
"descriptionPt": []
},
{
2015-06-09 13:30:57 -07:00
"id": "adf08ec01beb4f99fc7a68f2",
"title": "Falsy Bouncer",
"difficulty": "1.50",
"description": [
"Remove all falsy values from an array.",
"Falsy values in javascript are false, null, 0, \"\", undefined, and NaN.",
2015-08-26 23:23:46 -07:00
"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) {",
" // Don't show a false ID to this bouncer.",
" return arr;",
"}",
"",
2015-08-26 23:23:46 -07:00
"bouncer([7, \"ate\", \"\", false, 9], \"\");"
],
"tests": [
"assert.deepEqual(bouncer([7, \"ate\", \"\", false, 9]), [7, \"ate\", 9], 'message: <code>[7, \"ate\", \"\", false, 9]</code> should return <code>[7, \"ate\", 9]</code>.');",
"assert.deepEqual(bouncer([\"a\", \"b\", \"c\"]), [\"a\", \"b\", \"c\"], 'message: <code>[\"a\", \"b\", \"c\"]</code> should return <code>[\"a\", \"b\", \"c\"]</code>.');",
"assert.deepEqual(bouncer([false, null, 0, NaN, undefined, '']), [], 'message: <code>[false, null, 0]</code> should return <code>[]</code>.');"
],
"MDNlinks": [
"Boolean Objects",
"Array.filter()"
],
2015-08-07 23:37:32 -07:00
"type": "bonfire",
"challengeType": 5,
"nameCn": "",
"descriptionCn": [],
"nameFr": "",
"descriptionFr": [],
"nameRu": "",
"descriptionRu": [],
"nameEs": "",
"descriptionEs": [],
"namePt": "",
"descriptionPt": []
},
{
2015-06-09 13:30:57 -07:00
"id": "a39963a4c10bc8b4d4f06d7e",
2015-08-07 23:37:32 -07:00
"title": "Seek and Destroy",
"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.",
2015-08-26 23:23:46 -07:00
"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) {",
" // Remove all the values",
" return arr;",
"}",
"",
2015-08-26 23:23:46 -07:00
"destroyer([1, 2, 3, 1, 2, 3], 2, 3, \"\");"
],
"tests": [
"assert.deepEqual(destroyer([1, 2, 3, 1, 2, 3], 2, 3), [1, 1], 'message: <code>[1, 2, 3, 1, 2, 3], 2, 3</code> should return <code>[1, 1]</code>.');",
"assert.deepEqual(destroyer([1, 2, 3, 5, 1, 2, 3], 2, 3), [1, 5, 1], 'message: <code>[1, 2, 3, 5, 1, 2, 3], 2, 3</code> should return <code>[1, 5, 1]</code>.');",
"assert.deepEqual(destroyer([3, 5, 1, 2, 2], 2, 3, 5), [1], 'message: <code>[3, 5, 1, 2, 2], 2, 3, 5</code> should return <code>[1]</code>.');",
"assert.deepEqual(destroyer([2, 3, 2, 3], 2, 3), [], 'message: <code>[2, 3, 2, 3], 2, 3</code> should return <code>[]</code>.');",
"assert.deepEqual(destroyer([\"tree\", \"hamburger\", 53], \"tree\", 53), [\"hamburger\"], 'message: <code>[\"tree\", \"hamburger\", 53], \"tree\", 53)</code> should return <code>[\"hamburger\"]</code>.');"
],
"MDNlinks": [
"Arguments object",
"Array.filter()"
],
2015-08-07 23:37:32 -07:00
"type": "bonfire",
"challengeType": 5,
"nameCn": "",
"descriptionCn": [],
"nameFr": "",
"descriptionFr": [],
"nameRu": "",
"descriptionRu": [],
"nameEs": "",
"descriptionEs": [],
"namePt": "",
"descriptionPt": []
},
{
2015-06-09 13:30:57 -07:00
"id": "a24c1a4622e3c05097f71d67",
2015-08-07 23:37:32 -07:00
"title": "Where do I belong",
"difficulty": "1.61",
"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).",
2015-08-26 23:23:46 -07:00
"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) {",
" // Find my place in this sorted array.",
" return num;",
"}",
"",
2015-08-26 23:23:46 -07:00
"where([40, 60], 50, \"\");"
],
"MDNlinks": [
"Array.sort()"
],
"tests": [
"assert(where([10, 20, 30, 40, 50], 35) === 3, 'message: <code>[10, 20, 30, 40, 50], 35</code> should return <code>3</code>.');",
"assert(where([10, 20, 30, 40, 50], 30) === 2, 'message: <code>[10, 20, 30, 40, 50], 30)</code> should return <code>2</code>.');",
"assert(where([40, 60], 50) === 1, 'message: <code>[40, 60,], 50</code> should return <code>1</code>.');",
"assert(where([5, 3, 20, 3], 3) === 0, 'message: <code>[5, 3, 20, 3], 3</code> should return <code>0</code>.');",
"assert(where([2, 20, 10], 1) === 0, 'message: <code>[2, 20, 10], 1</code> should return <code>0</code>.');",
"assert(where([2, 5, 10], 15) === 3, 'message: <code>[2, 5, 10], 15</code> should return <code>3</code>.');"
],
2015-08-07 23:37:32 -07:00
"type": "bonfire",
"challengeType": 5,
"nameCn": "",
"descriptionCn": [],
"nameFr": "",
"descriptionFr": [],
"nameRu": "",
"descriptionRu": [],
"nameEs": "",
"descriptionEs": [],
"namePt": "",
"descriptionPt": []
}
]
2015-05-31 14:08:44 -07:00
}