freeCodeCamp/challenges/01-front-end-development-ce.../basic-bonfires.json

830 lines
48 KiB
JSON
Raw Normal View History

2015-06-03 03:32:10 +00:00
{
"name": "Basic Algorithm Scripting",
"order": 8,
"time": "50 hours",
2016-01-15 03:24:41 +00:00
"helpRoom": "HelpJavaScript",
2015-06-03 03:32:10 +00:00
"challenges": [
{
"id": "bd7158d2c442eddfbeb5bd1f",
"title": "Get Set for our Algorithm Challenges",
"challengeSeed": [],
"description": [
[
"http://i.imgur.com/sJkp30a.png",
"An image of a algorithm challenge showing directions, tests, and the code editor.",
"Our algorithm challenges will teach you how to think like a programmer.",
""
],
[
"http://i.imgur.com/d8LuRNh.png",
"A mother bird kicks a baby bird out of her nest.",
"Our previous challenges introduced you to programming concepts. But for these algorithm challenges, you'll now need to apply what you learned to solve open-ended problems.",
""
],
[
"http://i.imgur.com/WBetuBa.jpg",
"A programmer punching through his laptop screen in frustration.",
"Our algorithm challenges are hard. Some of them may take you several hours to solve. You will get frustrated. But don't quit.",
""
],
[
"http://i.imgur.com/p2TpOQd.jpg",
"A cute dog jumping over a hurdle and winking and pointing his paw at you.",
"When you get stuck, just use the Read-Search-Ask methodology.<br>Don't worry - you've got this.",
""
]
],
"type": "Waypoint",
"challengeType": 7,
"tests": [],
"nameCn": "",
"descriptionCn": [],
"nameFr": "",
"descriptionFr": [],
"nameRu": "",
"descriptionRu": [],
"nameEs": "Prepárate para los Ziplines",
"descriptionEs": [],
"namePt": "",
"descriptionPt": [],
"isRequired": true
2015-06-03 03:32:10 +00:00
},
{
"id": "a202eed8fc186c8434cb6d61",
2015-08-08 06:37:32 +00:00
"title": "Reverse a String",
2015-06-03 03:32:10 +00:00
"tests": [
2015-11-30 02:56:07 +00:00
"assert(typeof reverseString(\"hello\") === \"string\", 'message: <code>reverseString(\"hello\")</code> should return a string.');",
"assert(reverseString(\"hello\") === \"olleh\", 'message: <code>reverseString(\"hello\")</code> should become <code>\"olleh\"</code>.');",
"assert(reverseString(\"Howdy\") === \"ydwoH\", 'message: <code>reverseString(\"Howdy\")</code> should become <code>\"ydwoH\"</code>.');",
"assert(reverseString(\"Greetings from Earth\") === \"htraE morf sgniteerG\", 'message: <code>reverseString(\"Greetings from Earth\")</code> should return <code>\"htraE morf sgniteerG\"</code>.');"
2015-06-03 03:32:10 +00:00
],
"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-27 06:23:46 +00: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."
2015-06-03 03:32:10 +00:00
],
"challengeSeed": [
"function reverseString(str) {",
" return str;",
"}",
"",
"reverseString(\"hello\");"
2015-06-03 03:32:10 +00:00
],
"MDNlinks": [
"Global String Object",
"String.split()",
"Array.reverse()",
"Array.join()"
],
2015-10-22 01:04:33 +00:00
"solutions": [
"function reverseString(str) {\n return str.split('').reverse().join(\"\");\n}\n\nreverseString('hello');\n"
],
2015-08-08 06:37:32 +00:00
"type": "bonfire",
2015-06-03 03:32:10 +00:00
"challengeType": 5,
"nameCn": "",
"descriptionCn": [],
"nameFr": "",
"descriptionFr": [],
"nameRu": "",
"descriptionRu": [],
2015-11-13 15:26:48 +00:00
"nameEs": "Invierte el texto",
"descriptionEs": [
"Invierte la cadena de texto que se te provee",
"Puede que necesites convertir la cadena de texto en un arreglo antes de que puedas invertirla",
"El resultado debe ser una cadena de texto",
"Recuerda utilizar <a href='//github.com/FreeCodeCamp/freecodecamp/wiki/How-to-get-help-when-you-get-stuck' target='_blank'>Read-Search-Ask</a> si te sientes atascado. Intenta programar en pareja. Escribe tu propio código."
],
2015-06-03 03:32:10 +00:00
"namePt": "",
"descriptionPt": [],
"isRequired": true
2015-06-03 03:32:10 +00:00
},
{
"id": "a302f7aae1aa3152a5b413bc",
2015-08-08 06:37:32 +00:00
"title": "Factorialize a Number",
2015-06-03 03:32:10 +00:00
"tests": [
2015-11-30 02:56:07 +00:00
"assert(typeof factorialize(5) === 'number', 'message: <code>factorialize(5)</code> should return a number.');",
"assert(factorialize(5) === 120, 'message: <code>factorialize(5)</code> should return 120.');",
"assert(factorialize(10) === 3628800, 'message: <code>factorialize(10)</code> should return 3628800.');",
"assert(factorialize(20) === 2432902008176640000, 'message: <code>factorialize(20)</code> should return 2432902008176640000.');",
"assert(factorialize(0) === 1, 'message: <code>factorialize(0)</code> should return 1.');"
2015-06-03 03:32:10 +00:00
],
"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 22:18:40 +00: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-27 06:23:46 +00: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."
2015-06-03 03:32:10 +00:00
],
"challengeSeed": [
"function factorialize(num) {",
" return num;",
"}",
"",
"factorialize(5);"
2015-06-03 03:32:10 +00:00
],
"MDNlinks": [
"Arithmetic Operators"
],
2015-10-22 01:04:33 +00:00
"solutions": [
2015-11-02 01:20:03 +00:00
"function factorialize(num) {\n return num < 1 ? 1 : num * factorialize(num-1);\n}\n\nfactorialize(5);\n"
2015-10-22 01:04:33 +00:00
],
2015-08-08 06:37:32 +00:00
"type": "bonfire",
2015-06-03 03:32:10 +00:00
"challengeType": 5,
"nameCn": "",
"descriptionCn": [],
"nameFr": "",
"descriptionFr": [],
"nameRu": "",
"descriptionRu": [],
2015-11-13 15:26:48 +00:00
"nameEs": "Factoriza un número",
"descriptionEs": [
"Crea una función que devuelva el factorial del número entero que se te provee",
"El factorial de un número entero positivo n es la multiplicación de todos los enteros positivos menores o iguales a n",
"Los factoriales son comúnmente representados con la notación <code>n!</code>",
"Por ejemplo: <code>5! = 1 * 2 * 3 * 4 * 5 = 120</code>",
"Recuerda utilizar <a href='//github.com/FreeCodeCamp/freecodecamp/wiki/How-to-get-help-when-you-get-stuck' target='_blank'>Read-Search-Ask</a> si te sientes atascado. Intenta programar en pareja. Escribe tu propio código."
],
2015-06-03 03:32:10 +00:00
"namePt": "",
"descriptionPt": [],
"isRequired": true
2015-06-03 03:32:10 +00:00
},
{
"id": "aaa48de84e1ecc7c742e1124",
2015-08-08 06:37:32 +00:00
"title": "Check for Palindromes",
2015-06-03 03:32:10 +00:00
"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 all non-alphanumeric characters (punctuation, spaces and symbols) and turn everything lower case in order to check for palindromes.",
2015-06-03 03:32:10 +00:00
"We'll pass strings with varying formats, such as \"racecar\", \"RaceCar\", and \"race CAR\" among others.",
2015-08-27 06:23:46 +00: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."
2015-06-03 03:32:10 +00:00
],
"tests": [
2015-11-30 02:56:07 +00:00
"assert(typeof palindrome(\"eye\") === \"boolean\", 'message: <code>palindrome(\"eye\")</code> should return a boolean.');",
"assert(palindrome(\"eye\") === true, 'message: <code>palindrome(\"eye\")</code> should return true.');",
"assert(palindrome(\"race car\") === true, 'message: <code>palindrome(\"race car\")</code> should return true.');",
"assert(palindrome(\"not a palindrome\") === false, 'message: <code>palindrome(\"not a palindrome\")</code> should return false.');",
"assert(palindrome(\"A man, a plan, a canal. Panama\") === true, 'message: <code>palindrome(\"A man, a plan, a canal. Panama\")</code> should return true.');",
"assert(palindrome(\"never odd or even\") === true, 'message: <code>palindrome(\"never odd or even\")</code> should return true.');",
"assert(palindrome(\"nope\") === false, 'message: <code>palindrome(\"nope\")</code> should return false.');",
"assert(palindrome(\"almostomla\") === false, 'message: <code>palindrome(\"almostomla\")</code> should return false.');",
"assert(palindrome(\"My age is 0, 0 si ega ym.\") === true, 'message: <code>palindrome(\"My age is 0, 0 si ega ym.\")</code> should return true.');",
"assert(palindrome(\"1 eye for of 1 eye.\") === false, 'message: <code>palindrome(\"1 eye for of 1 eye.\")</code> should return false.');",
2015-10-16 09:10:47 +00:00
"assert(palindrome(\"0_0 (: /-\\ :) 0-0\") === true, 'message: <code>palindrome(\"0_0 (: /-\\ :) 0-0\")</code> should return true.');"
2015-06-03 03:32:10 +00:00
],
"challengeSeed": [
"function palindrome(str) {",
" // Good luck!",
" return true;",
"}",
"",
"",
"",
"palindrome(\"eye\");"
],
"MDNlinks": [
"String.replace()",
"String.toLowerCase()"
],
2015-10-22 01:04:33 +00:00
"solutions": [
"function palindrome(str) {\n var string = str.toLowerCase().split(/[^A-Za-z0-9]/gi).join('');\n var aux = string.split('');\n if (aux.join('') === aux.reverse().join('')){\n return true;\n }\n\n return false;\n}"
2015-10-22 01:04:33 +00:00
],
2015-08-08 06:37:32 +00:00
"type": "bonfire",
2015-06-03 03:32:10 +00:00
"challengeType": 5,
"nameCn": "",
"descriptionCn": [],
"nameFr": "",
"descriptionFr": [],
"nameRu": "",
"descriptionRu": [],
2015-11-13 15:26:48 +00:00
"nameEs": "Verifica si es palíndromo",
"descriptionEs": [
"Crea una función que devuelva true si una cadena de texto dada es un palíndromo, y que devuelva false en caso contrario",
"Un palíndromo es una palabra u oración que se escribe de la misma forma en ambos sentidos, sin tomar en cuenta signos de puntuación, espacios y sin distinguir entre mayúsculas y minúsculas.",
"Tendrás que quitar los signos de puntuación y transformar las letras a minúsculas para poder verificar si el texto es palíndromo.",
"Te proveeremos textos en varios formatos, como \"racecar\", \"RaceCar\", and \"race CAR\" entre otros.",
"Recuerda utilizar <a href='//github.com/FreeCodeCamp/freecodecamp/wiki/How-to-get-help-when-you-get-stuck' target='_blank'>Read-Search-Ask</a> si te sientes atascado. Intenta programar en pareja. Escribe tu propio código."
],
2015-06-03 03:32:10 +00:00
"namePt": "",
"descriptionPt": [],
"isRequired": true
2015-06-03 03:32:10 +00:00
},
{
"id": "a26cbbe9ad8655a977e1ceb5",
2015-08-08 06:37:32 +00:00
"title": "Find the Longest Word in a String",
2015-06-03 03:32:10 +00:00
"description": [
"Return the length of the longest word in the provided sentence.",
"Your response should be a number.",
2015-08-27 06:23:46 +00: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."
2015-06-03 03:32:10 +00:00
],
"challengeSeed": [
"function findLongestWord(str) {",
" return str.length;",
"}",
"",
2015-08-27 06:23:46 +00:00
"findLongestWord(\"The quick brown fox jumped over the lazy dog\");"
2015-06-03 03:32:10 +00:00
],
"tests": [
2015-11-30 02:56:07 +00:00
"assert(typeof findLongestWord(\"The quick brown fox jumped over the lazy dog\") === \"number\", 'message: <code>findLongestWord(\"The quick brown fox jumped over the lazy dog\")</code> should return a number.');",
"assert(findLongestWord(\"The quick brown fox jumped over the lazy dog\") === 6, 'message: <code>findLongestWord(\"The quick brown fox jumped over the lazy dog\")</code> should return 6.');",
"assert(findLongestWord(\"May the force be with you\") === 5, 'message: <code>findLongestWord(\"May the force be with you\")</code> should return 5.');",
"assert(findLongestWord(\"Google do a barrel roll\") === 6, 'message: <code>findLongestWord(\"Google do a barrel roll\")</code> should return 6.');",
"assert(findLongestWord(\"What is the average airspeed velocity of an unladen swallow\") === 8, 'message: <code>findLongestWord(\"What is the average airspeed velocity of an unladen swallow\")</code> should return 8.');",
"assert(findLongestWord(\"What if we try a super-long word such as otorhinolaryngology\") === 19, 'message: <code>findLongestWord(\"What if we try a super-long word such as otorhinolaryngology\")</code> should return 19.');"
2015-06-03 03:32:10 +00:00
],
"MDNlinks": [
"String.split()",
"String.length"
],
2015-10-22 01:04:33 +00:00
"solutions": [
"function findLongestWord(str) {\n return str.split(' ').sort(function(a, b) { return b.length - a.length;})[0].length;\n}\n\nfindLongestWord('The quick brown fox jumped over the lazy dog');\n"
],
2015-08-08 06:37:32 +00:00
"type": "bonfire",
2015-06-03 03:32:10 +00:00
"challengeType": 5,
"nameCn": "",
"descriptionCn": [],
"nameFr": "",
"descriptionFr": [],
"nameRu": "",
"descriptionRu": [],
2015-11-13 15:26:48 +00:00
"nameEs": "Encuentra la palabra más larga",
"descriptionEs": [
"Crea una función que devuelva la longitud de la palabra más larga en una frase dada",
"El resultado debe ser un número",
"Recuerda utilizar <a href='//github.com/FreeCodeCamp/freecodecamp/wiki/How-to-get-help-when-you-get-stuck' target='_blank'>Read-Search-Ask</a> si te sientes atascado. Intenta programar en pareja. Escribe tu propio código."
],
2015-06-03 03:32:10 +00:00
"namePt": "",
"descriptionPt": [],
"isRequired": true
2015-06-03 03:32:10 +00:00
},
{
"id": "ab6137d4e35944e21037b769",
2015-08-08 06:37:32 +00:00
"title": "Title Case a Sentence",
2015-06-03 03:32:10 +00:00
"description": [
2015-09-14 21:30:53 +00: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-27 06:23:46 +00: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."
2015-06-03 03:32:10 +00:00
],
"challengeSeed": [
"function titleCase(str) {",
" return str;",
"}",
"",
"titleCase(\"I'm a little tea pot\");"
2015-06-03 03:32:10 +00:00
],
"tests": [
2015-11-30 02:56:07 +00:00
"assert(typeof titleCase(\"I'm a little tea pot\") === \"string\", 'message: <code>titleCase(\"I&#39;m a little tea pot\")</code> should return a string.');",
2015-10-31 05:00:47 +00:00
"assert(titleCase(\"I'm a little tea pot\") === \"I'm A Little Tea Pot\", 'message: <code>titleCase(\"I&#39;m a little tea pot\")</code> should return \"I&#39;m A Little Tea Pot\".');",
"assert(titleCase(\"sHoRt AnD sToUt\") === \"Short And Stout\", 'message: <code>titleCase(\"sHoRt AnD sToUt\")</code> should return \"Short And Stout\".');",
"assert(titleCase(\"HERE IS MY HANDLE HERE IS MY SPOUT\") === \"Here Is My Handle Here Is My Spout\", 'message: <code>titleCase(\"HERE IS MY HANDLE HERE IS MY SPOUT\")</code> should return \"Here Is My Handle Here Is My Spout\".');"
2015-06-03 03:32:10 +00:00
],
"MDNlinks": [
"String.split()"
2015-06-03 03:32:10 +00:00
],
2015-10-22 01:04:33 +00:00
"solutions": [
"function titleCase(str) {\n return str.split(' ').map(function(word) {\n return word.charAt(0).toUpperCase() + word.substring(1).toLowerCase();\n }).join(' ');\n}\n\ntitleCase(\"I'm a little tea pot\");\n"
],
2015-08-08 06:37:32 +00:00
"type": "bonfire",
2015-06-03 03:32:10 +00:00
"challengeType": 5,
"nameCn": "",
"descriptionCn": [],
"nameFr": "",
"descriptionFr": [],
"nameRu": "",
"descriptionRu": [],
2015-11-13 15:26:48 +00:00
"nameEs": "Aplica formato de título",
"descriptionEs": [
"Crea una función que devuelva la cadena de texto dada con la primera letra de cada palabra en mayúscula. Asegúrate de que el resto de las letras sean minúsculas",
"Para este ejercicio, también debes poner en mayúscula conectores como \"the\" y \"of\".",
"Recuerda utilizar <a href='//github.com/FreeCodeCamp/freecodecamp/wiki/How-to-get-help-when-you-get-stuck' target='_blank'>Read-Search-Ask</a> si te sientes atascado. Intenta programar en pareja. Escribe tu propio código."
],
2015-06-03 03:32:10 +00:00
"namePt": "",
"descriptionPt": [],
"isRequired": true
2015-06-03 03:32:10 +00:00
},
{
"id": "a789b3483989747d63b0e427",
2015-08-08 06:37:32 +00:00
"title": "Return Largest Numbers in Arrays",
2015-06-03 03:32:10 +00:00
"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] .",
2015-08-27 06:23:46 +00: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."
2015-06-03 03:32:10 +00:00
],
"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]]);"
2015-06-03 03:32:10 +00:00
],
"tests": [
2015-11-30 02:56:07 +00:00
"assert(largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]).constructor === Array, 'message: <code>largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]])</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>largestOfFour([[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>largestOfFour([[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>.');"
2015-06-03 03:32:10 +00:00
],
"MDNlinks": [
"Comparison Operators"
],
"solutions": [
"function largestOfFour(arr) {\n return arr.map(function(subArr) {\n return Math.max.apply(null, subArr);\n });\n}\n\nlargestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);\n"
],
2015-08-08 06:37:32 +00:00
"type": "bonfire",
2015-06-03 03:32:10 +00:00
"challengeType": 5,
"nameCn": "",
"descriptionCn": [],
"nameFr": "",
"descriptionFr": [],
"nameRu": "",
"descriptionRu": [],
2015-11-13 15:26:48 +00:00
"nameEs": "Devuelve el entero mayor en cada arreglo",
"descriptionEs": [
"Crea una función que devuelva un arreglo que contenga el mayor de los números de cada sub-arreglo que se te presenta. Para simplificar las cosas, el arreglo que te presentamos tendrá exactamente 4 sub-arreglos",
"Recuerda que puedes iterar a través de un arreglo con un búcle simple, y acceder a cada miembro utilizando la sintaxis arr[i].",
"Si escribes tu propio test con Chai.js, asegúrate de utilizar un operador de igualdad estricto en lugar de un operador de igualdad cuando compares arreglos. ",
"Recuerda utilizar <a href='//github.com/FreeCodeCamp/freecodecamp/wiki/How-to-get-help-when-you-get-stuck' target='_blank'>Read-Search-Ask</a> si te sientes atascado. Intenta programar en pareja. Escribe tu propio código."
],
2015-06-03 03:32:10 +00:00
"namePt": "",
"descriptionPt": [],
"isRequired": true
2015-06-03 03:32:10 +00:00
},
{
"id": "acda2fb1324d9b0fa741e6b5",
2015-08-08 06:37:32 +00:00
"title": "Confirm the Ending",
2015-06-03 03:32:10 +00:00
"description": [
"Check if a string (first argument) ends with the given target string (second argument).",
2015-08-27 06:23:46 +00: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."
2015-06-03 03:32:10 +00:00
],
"challengeSeed": [
"function end(str, target) {",
" // \"Never give up and good luck will find you.\"",
" // -- Falcor",
" return str;",
"}",
"",
"end(\"Bastian\", \"n\");"
2015-06-03 03:32:10 +00:00
],
"tests": [
"assert(end(\"Bastian\", \"n\") === true, 'message: <code>end(\"Bastian\", \"n\")</code> should return true.');",
"assert(end(\"Connor\", \"n\") === false, 'message: <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, 'message: <code>end(\"Walking on water and developing software from a specification are easy if both are frozen\"&#44; \"specification\"&#41;</code> should return false.');",
"assert(end(\"He has to give me a new name\", \"name\") === true, 'message: <code>end(\"He has to give me a new name\", \"name\")</code> should return true.');",
"assert(end(\"He has to give me a new name\", \"me\") === true, 'message: <code>end(\"He has to give me a new name\", \"me\")</code> should return true.');",
"assert(end(\"He has to give me a new name\", \"na\") === false, 'message: <code>end(\"He has to give me a new name\", \"na\")</code> should return false.');",
"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>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.');"
2015-06-03 03:32:10 +00:00
],
"MDNlinks": [
"String.substr()"
],
"solutions": [
"function end(str, target) {\n return str.substring(str.length-target.length) === target;\n};\n"
],
2015-08-08 06:37:32 +00:00
"type": "bonfire",
2015-06-03 03:32:10 +00:00
"challengeType": 5,
"nameCn": "",
"descriptionCn": [],
"nameFr": "",
"descriptionFr": [],
"nameRu": "",
"descriptionRu": [],
2015-11-13 15:26:48 +00:00
"nameEs": "Confirma la terminación",
"descriptionEs": [
"Verifica si una cadena de texto (primer argumento) termina con una cadena de texto dada (segundo argumento).",
"Recuerda utilizar <a href='//github.com/FreeCodeCamp/freecodecamp/wiki/How-to-get-help-when-you-get-stuck' target='_blank'>Read-Search-Ask</a> si te sientes atascado. Intenta programar en pareja. Escribe tu propio código."
],
2015-06-03 03:32:10 +00:00
"namePt": "",
"descriptionPt": [],
"isRequired": true
2015-06-03 03:32:10 +00:00
},
{
"id": "afcc8d540bea9ea2669306b6",
2015-08-08 06:37:32 +00:00
"title": "Repeat a string repeat a string",
2015-06-03 03:32:10 +00:00
"description": [
"Repeat a given string (first argument) n times (second argument). Return an empty string if n is a negative number.",
2015-08-27 06:23:46 +00: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."
2015-06-03 03:32:10 +00:00
],
"challengeSeed": [
"function repeat(str, num) {",
" // repeat after me",
" return str;",
"}",
"",
"repeat(\"abc\", 3);"
2015-06-03 03:32:10 +00:00
],
"tests": [
"assert(repeat(\"*\", 3) === \"***\", 'message: <code>repeat(\"*\", 3)</code> should return <code>\"***\"</code>.');",
"assert(repeat(\"abc\", 3) === \"abcabcabc\", 'message: <code>repeat(\"abc\", 3)</code> should return <code>\"abcabcabc\"</code>.');",
2015-11-07 00:20:04 +00:00
"assert(repeat(\"abc\", 4) === \"abcabcabcabc\", 'message: <code>repeat(\"abc\", 4)</code> should return <code>\"abcabcabcabc\"</code>.');",
"assert(repeat(\"abc\", 1) === \"abc\", 'message: <code>repeat(\"abc\", 1)</code> should return <code>\"abc\"</code>.');",
2015-11-09 01:03:43 +00:00
"assert(repeat(\"*\", 8) === \"********\", 'message: <code>repeat(\"*\", 8)</code> should return <code>\"********\"</code>.');",
"assert(repeat(\"abc\", -2) === \"\", 'message: <code>repeat(\"abc\", -2)</code> should return <code>\"\"</code>.');"
2015-06-03 03:32:10 +00:00
],
"MDNlinks": [
"Global String Object"
],
"solutions": [
"function repeat(str, num) {\n if (num < 0) return '';\n return num === 1 ? str : str + repeat(str, num-1);\n}\n\nrepeat('abc', 3);\n"
],
2015-08-08 06:37:32 +00:00
"type": "bonfire",
2015-06-03 03:32:10 +00:00
"challengeType": 5,
"nameCn": "",
"descriptionCn": [],
"nameFr": "",
"descriptionFr": [],
"nameRu": "",
"descriptionRu": [],
2015-11-13 15:26:48 +00:00
"nameEs": "Repite el texto Repite el texto",
"descriptionEs": [
"Repite una cadena de texto dada (primer argumento) n veces (segundo argumento). Devuelve una cadena de texto vacía si n es un número negativo.",
"Recuerda utilizar <a href='//github.com/FreeCodeCamp/freecodecamp/wiki/How-to-get-help-when-you-get-stuck' target='_blank'>Read-Search-Ask</a> si te sientes atascado. Intenta programar en pareja. Escribe tu propio código."
],
2015-06-03 03:32:10 +00:00
"namePt": "",
"descriptionPt": [],
"isRequired": true
2015-06-03 03:32:10 +00:00
},
{
"id": "ac6993d51946422351508a41",
2015-08-08 06:37:32 +00:00
"title": "Truncate a string",
2015-06-03 03:32:10 +00:00
"description": [
2015-08-27 06:23:46 +00: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.",
2015-06-03 03:32:10 +00:00
"Note that the three dots at the end add to the string length.",
"If the <code>num</code> is less than or equal to 3, then the length of the three dots is not added to the string length.",
2015-08-27 06:23:46 +00: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."
2015-06-03 03:32:10 +00:00
],
"challengeSeed": [
"function truncate(str, num) {",
" // Clear out that junk in your trunk",
" return str;",
"}",
"",
"truncate(\"A-tisket a-tasket A green and yellow basket\", 11);"
2015-06-03 03:32:10 +00:00
],
"tests": [
"assert(truncate(\"A-tisket a-tasket A green and yellow basket\", 11) === \"A-tisket...\", 'message: <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...\", 'message: <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\", 'message: <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\".');",
2015-10-15 08:58:19 +00:00
"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>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\".');",
2015-11-06 18:26:56 +00:00
"assert(truncate(\"A-\", 1) === \"A...\", 'message: <code>truncate(\"A-\", 1)</code> should return \"A...\".');",
2015-12-09 17:12:50 +00:00
"assert(truncate(\"Absolutely Longer\", 2) === \"Ab...\", 'message: <code>truncate(\"Absolutely Longer\", 2)</code> should return \"Ab...\".');"
2015-06-03 03:32:10 +00:00
],
"MDNlinks": [
"String.slice()"
],
"solutions": [
2015-11-06 18:26:56 +00:00
"function truncate(str, num) {\n if(str.length > num ) {\n if(num > 3) {\n return str.slice(0, num - 3) + '...';\n } else {\n return str.slice(0,num) + '...';\n }\n } \n return str;\n}"
],
2015-08-08 06:37:32 +00:00
"type": "bonfire",
2015-06-03 03:32:10 +00:00
"challengeType": 5,
"nameCn": "",
"descriptionCn": [],
"nameFr": "",
"descriptionFr": [],
"nameRu": "",
"descriptionRu": [],
2015-11-13 15:26:48 +00:00
"nameEs": "Trunca una cadena de texto",
"descriptionEs": [
"Trunca una cadena de texto (primer argumento) si su longitud es mayor que un máximo de caracteres dado (segundo argumento). Devuelve la cadena de texto truncada con una terminación \"...\".",
"Ten en cuenta que los tres puntos al final también se cuentan dentro de la longitud de la cadena de texto.",
"Recuerda utilizar <a href='//github.com/FreeCodeCamp/freecodecamp/wiki/How-to-get-help-when-you-get-stuck' target='_blank'>Read-Search-Ask</a> si te sientes atascado. Intenta programar en pareja. Escribe tu propio código."
],
2015-06-03 03:32:10 +00:00
"namePt": "",
"descriptionPt": [],
"isRequired": true
2015-06-03 03:32:10 +00:00
},
{
"id": "a9bd25c716030ec90084d8a1",
2015-08-08 06:37:32 +00:00
"title": "Chunky Monkey",
2015-06-03 03:32:10 +00:00
"description": [
"Write a function that splits an array (first argument) into groups the length of <code>size</code> (second argument) and returns them as a multidimensional array.",
2015-08-27 06:23:46 +00: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."
2015-06-03 03:32:10 +00:00
],
"challengeSeed": [
"function chunk(arr, size) {",
" // Break it up.",
" return arr;",
"}",
"",
"chunk([\"a\", \"b\", \"c\", \"d\"], 2);"
2015-06-03 03:32:10 +00:00
],
"tests": [
"assert.deepEqual(chunk([\"a\", \"b\", \"c\", \"d\"], 2), [[\"a\", \"b\"], [\"c\", \"d\"]], 'message: <code>chunk([\"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>chunk([0, 1, 2, 3, 4, 5], 3)</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>chunk([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>chunk([0, 1, 2, 3, 4, 5], 4)</code> should return <code>[[0, 1, 2, 3], [4, 5]]</code>.');",
"assert.deepEqual(chunk([0, 1, 2, 3, 4, 5, 6], 3), [[0, 1, 2], [3, 4, 5], [6]], 'message: <code>chunk([0, 1, 2, 3, 4, 5, 6], 3)</code> should return <code>[[0, 1, 2], [3, 4, 5], [6]]</code>.');",
"assert.deepEqual(chunk([0, 1, 2, 3, 4, 5, 6, 7, 8], 4), [[0, 1, 2, 3], [4, 5, 6, 7], [8]], 'message: <code>chunk([0, 1, 2, 3, 4, 5, 6, 7, 8], 4)</code> should return <code>[[0, 1, 2, 3], [4, 5, 6, 7], [8]]</code>.');"
2015-06-03 03:32:10 +00:00
],
"MDNlinks": [
"Array.push()",
"Array.slice()"
2015-06-03 03:32:10 +00:00
],
"solutions": [
"function chunk(arr, size) {\n var out = [];\n for (var i = 0; i < arr.length; i+=size) {\n out.push(arr.slice(i,i+size));\n }\n return out;\n}\n\nchunk(['a', 'b', 'c', 'd'], 2);\n"
],
2015-08-08 06:37:32 +00:00
"type": "bonfire",
2015-06-03 03:32:10 +00:00
"challengeType": 5,
"nameCn": "",
"descriptionCn": [],
"nameFr": "",
"descriptionFr": [],
"nameRu": "",
"descriptionRu": [],
2015-11-13 15:26:48 +00:00
"nameEs": "En mil pedazos",
"descriptionEs": [
"Escribe una función que parta un arreglo (primer argumento) en fragmentos de una longitud dada (segundo argumento) y los devuelva en forma de un arreglo multidimensional.",
"Recuerda utilizar <a href='//github.com/FreeCodeCamp/freecodecamp/wiki/How-to-get-help-when-you-get-stuck' target='_blank'>Read-Search-Ask</a> si te sientes atascado. Intenta programar en pareja. Escribe tu propio código."
],
2015-06-03 03:32:10 +00:00
"namePt": "",
"descriptionPt": [],
"isRequired": true
2015-06-03 03:32:10 +00:00
},
{
"id": "ab31c21b530c0dafa9e241ee",
2015-08-08 06:37:32 +00:00
"title": "Slasher Flick",
2015-06-03 03:32:10 +00:00
"description": [
"Return the remaining elements of an array after chopping off n elements from the head.",
"The head meaning the beginning of the array, or the zeroth index",
2015-08-27 06:23:46 +00: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."
2015-06-03 03:32:10 +00:00
],
"challengeSeed": [
"function slasher(arr, howMany) {",
" // it doesn't always pay to be first",
" return arr;",
"}",
"",
"slasher([1, 2, 3], 2);"
2015-06-03 03:32:10 +00:00
],
"tests": [
"assert.deepEqual(slasher([1, 2, 3], 2), [3], 'message: <code>slasher([1, 2, 3], 2)</code> should return <code>[3]</code>.');",
"assert.deepEqual(slasher([1, 2, 3], 0), [1, 2, 3], 'message: <code>slasher([1, 2, 3], 0)</code> should return <code>[1, 2, 3]</code>.');",
"assert.deepEqual(slasher([1, 2, 3], 9), [], 'message: <code>slasher([1, 2, 3], 9)</code> should return <code>[]</code>.');",
"assert.deepEqual(slasher([1, 2, 3], 4), [], 'message: <code>slasher([1, 2, 3], 4)</code> should return <code>[]</code>.');"
2015-06-03 03:32:10 +00:00
],
"MDNlinks": [
"Array.slice()",
"Array.splice()"
],
"solutions": [
"function slasher(arr, howMany) {\n // it doesn't always pay to be first\n return arr.slice(howMany);\n}\n\nslasher([1, 2, 3], 2);\n"
],
2015-08-08 06:37:32 +00:00
"type": "bonfire",
2015-06-03 03:32:10 +00:00
"challengeType": 5,
"nameCn": "",
"descriptionCn": [],
"nameFr": "",
"descriptionFr": [],
"nameRu": "",
"descriptionRu": [],
2015-11-13 15:26:48 +00:00
"nameEs": "Vuélale la cabeza",
"descriptionEs": [
"Crea una función que devuelva los elementos restantes de un arreglo después de eliminar n elementos de la cabeza.",
"Por cabeza nos referimos al inicio de un arreglo, comenzando por el índice 0.",
"Recuerda utilizar <a href='//github.com/FreeCodeCamp/freecodecamp/wiki/How-to-get-help-when-you-get-stuck' target='_blank'>Read-Search-Ask</a> si te sientes atascado. Intenta programar en pareja. Escribe tu propio código."
],
2015-06-03 03:32:10 +00:00
"namePt": "",
"descriptionPt": [],
"isRequired": true
2015-06-03 03:32:10 +00:00
},
{
"id": "af2170cad53daa0770fabdea",
2015-08-08 06:37:32 +00:00
"title": "Mutations",
2015-06-03 03:32:10 +00:00
"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-27 06:23:46 +00: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."
2015-06-03 03:32:10 +00:00
],
"challengeSeed": [
"function mutation(arr) {",
" return arr;",
"}",
"",
"mutation([\"hello\", \"hey\"]);"
2015-06-03 03:32:10 +00:00
],
"tests": [
"assert(mutation([\"hello\", \"hey\"]) === false, 'message: <code>mutation([\"hello\", \"hey\"])</code> should return false.');",
"assert(mutation([\"hello\", \"Hello\"]) === true, 'message: <code>mutation([\"hello\", \"Hello\"])</code> should return true.');",
"assert(mutation([\"zyxwvutsrqponmlkjihgfedcba\", \"qrstu\"]) === true, 'message: <code>mutation([\"zyxwvutsrqponmlkjihgfedcba\", \"qrstu\"])</code> should return true.');",
"assert(mutation([\"Mary\", \"Army\"]) === true, 'message: <code>mutation([\"Mary\", \"Army\"])</code> should return true.');",
"assert(mutation([\"Mary\", \"Aarmy\"]) === true, 'message: <code>mutation([\"Mary\", \"Aarmy\"])</code> should return true.');",
"assert(mutation([\"Alien\", \"line\"]) === true, 'message: <code>mutation([\"Alien\", \"line\"])</code> should return true.');",
"assert(mutation([\"floor\", \"for\"]) === true, 'message: <code>mutation([\"floor\", \"for\"])</code> should return true.');",
"assert(mutation([\"hello\", \"neo\"]) === false, 'message: <code>mutation([\"hello\", \"neo\"])</code> should return false.');"
2015-06-03 03:32:10 +00:00
],
"MDNlinks": [
"String.indexOf()"
2015-06-03 03:32:10 +00:00
],
"solutions": [
"function mutation(arr) {\n var hash = Object.create(null);\n arr[0].toLowerCase().split('').forEach(function(c) {\n hash[c] = true;\n });\n return !arr[1].toLowerCase().split('').filter(function(c) {\n return !hash[c];\n }).length;\n}\n\nmutation(['hello', 'hey']);\n"
],
2015-08-08 06:37:32 +00:00
"type": "bonfire",
2015-06-03 03:32:10 +00:00
"challengeType": 5,
"nameCn": "",
"descriptionCn": [],
"nameFr": "",
"descriptionFr": [],
"nameRu": "",
"descriptionRu": [],
2015-11-13 15:26:48 +00:00
"nameEs": "Mutaciones",
"descriptionEs": [
"Crea una función que devuelva true si la cadena de texto en el primer elemento de un arreglo contiene todas las letras de la cadena de texto en el segundo elemento del arreglo.",
"Por ejemplo, <code>[\"hello\", \"Hello\"]</code>, debe devolver true porque todas las letras en la segunda cadena de texto están presentes en la primera, sin distinguir entre mayúsculas y minúsculas.",
"En el caso de <code>[\"hello\", \"hey\"]</code> la función debe devolver false porque la cadena de texto \"hello\" no contiene una \"y\".",
"Finalmente, <code>[\"Alien\", \"line\"]</code>, la función debe devolver true porque todas las letras en \"line\" están presentes en \"Alien\".",
"Recuerda utilizar <a href='//github.com/FreeCodeCamp/freecodecamp/wiki/How-to-get-help-when-you-get-stuck' target='_blank'>Read-Search-Ask</a> si te sientes atascado. Intenta programar en pareja. Escribe tu propio código."
],
2015-06-03 03:32:10 +00:00
"namePt": "",
"descriptionPt": [],
"isRequired": true
2015-06-03 03:32:10 +00:00
},
{
"id": "adf08ec01beb4f99fc7a68f2",
"title": "Falsy Bouncer",
2015-06-03 03:32:10 +00:00
"description": [
"Remove all falsy values from an array.",
"Falsy values in javascript are <code>false</code>, <code>null</code>, <code>0</code>, <code>\"\"</code>, <code>undefined</code>, and <code>NaN</code>.",
2015-08-27 06:23:46 +00: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."
2015-06-03 03:32:10 +00:00
],
"challengeSeed": [
"function bouncer(arr) {",
" // Don't show a false ID to this bouncer.",
" return arr;",
"}",
"",
"bouncer([7, \"ate\", \"\", false, 9]);"
2015-06-03 03:32:10 +00:00
],
"tests": [
"assert.deepEqual(bouncer([7, \"ate\", \"\", false, 9]), [7, \"ate\", 9], 'message: <code>bouncer([7, \"ate\", \"\", false, 9])</code> should return <code>[7, \"ate\", 9]</code>.');",
"assert.deepEqual(bouncer([\"a\", \"b\", \"c\"]), [\"a\", \"b\", \"c\"], 'message: <code>bouncer([\"a\", \"b\", \"c\"])</code> should return <code>[\"a\", \"b\", \"c\"]</code>.');",
"assert.deepEqual(bouncer([false, null, 0, NaN, undefined, \"\"]), [], 'message: <code>bouncer([false, null, 0, NaN, undefined, \"\"])</code> should return <code>[]</code>.');"
2015-06-03 03:32:10 +00:00
],
"MDNlinks": [
"Boolean Objects",
"Array.filter()"
],
"solutions": [
"function bouncer(arr) {\n // Don't show a false ID to this bouncer.\n return arr.filter(function(e) {return e;});\n}\n\nbouncer([7, 'ate', '', false, 9]);\n"
],
2015-08-08 06:37:32 +00:00
"type": "bonfire",
2015-06-03 03:32:10 +00:00
"challengeType": 5,
"nameCn": "",
"descriptionCn": [],
"nameFr": "",
"descriptionFr": [],
"nameRu": "",
"descriptionRu": [],
2015-11-13 15:26:48 +00:00
"nameEs": "Detector de mentiras",
"descriptionEs": [
"Remueve todos los valores falsy de un arreglo dado",
"En javascript, valores falsy son los siguientes: <code>false</code>, <code>null</code>, <code>0</code>, <code>\"\"</code>, <code>undefined</code>, y <code>NaN</code>.",
"Recuerda utilizar <a href='//github.com/FreeCodeCamp/freecodecamp/wiki/How-to-get-help-when-you-get-stuck' target='_blank'>Read-Search-Ask</a> si te sientes atascado. Intenta programar en pareja. Escribe tu propio código."
],
2015-06-03 03:32:10 +00:00
"namePt": "",
"descriptionPt": [],
"isRequired": true
2015-06-03 03:32:10 +00:00
},
{
"id": "a39963a4c10bc8b4d4f06d7e",
2015-08-08 06:37:32 +00:00
"title": "Seek and Destroy",
2015-06-03 03:32:10 +00:00
"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-27 06:23:46 +00: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."
2015-06-03 03:32:10 +00:00
],
"challengeSeed": [
"function destroyer(arr) {",
" // Remove all the values",
" return arr;",
"}",
"",
"destroyer([1, 2, 3, 1, 2, 3], 2, 3);"
2015-06-03 03:32:10 +00:00
],
"tests": [
"assert.deepEqual(destroyer([1, 2, 3, 1, 2, 3], 2, 3), [1, 1], 'message: <code>destroyer([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>destroyer([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>destroyer([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>destroyer([2, 3, 2, 3], 2, 3)</code> should return <code>[]</code>.');",
"assert.deepEqual(destroyer([\"tree\", \"hamburger\", 53], \"tree\", 53), [\"hamburger\"], 'message: <code>destroyer([\"tree\", \"hamburger\", 53], \"tree\", 53)</code> should return <code>[\"hamburger\"]</code>.');"
2015-06-03 03:32:10 +00:00
],
"MDNlinks": [
"Arguments object",
"Array.filter()"
],
"solutions": [
"function destroyer(arr) {\n var hash = Object.create(null);\n [].slice.call(arguments, 1).forEach(function(e) {\n hash[e] = true;\n });\n // Remove all the values\n return arr.filter(function(e) { return !(e in hash);});\n}\n\ndestroyer([1, 2, 3, 1, 2, 3], 2, 3);\n"
],
2015-08-08 06:37:32 +00:00
"type": "bonfire",
2015-06-03 03:32:10 +00:00
"challengeType": 5,
"nameCn": "",
"descriptionCn": [],
"nameFr": "",
"descriptionFr": [],
"nameRu": "",
"descriptionRu": [],
2015-11-13 15:26:48 +00:00
"nameEs": "Buscar y destruir",
"descriptionEs": [
"Se te proveerá un arreglo inicial (el primer argumento en la función destroyer), seguido por uno o más argumentos. Elimina todos los elementos del arreglo inicial que tengan el mismo valor que el resto de argumentos.",
"Recuerda utilizar <a href='//github.com/FreeCodeCamp/freecodecamp/wiki/How-to-get-help-when-you-get-stuck' target='_blank'>Read-Search-Ask</a> si te sientes atascado. Intenta programar en pareja. Escribe tu propio código."
],
2015-06-03 03:32:10 +00:00
"namePt": "",
"descriptionPt": [],
"isRequired": true
2015-06-03 03:32:10 +00:00
},
{
"id": "a24c1a4622e3c05097f71d67",
2015-08-08 06:37:32 +00:00
"title": "Where do I belong",
2015-06-03 03:32:10 +00:00
"description": [
"Return the lowest index at which a value (second argument) should be inserted into an array (first argument) once it has been sorted.",
"For example, <code>where([1,2,3,4], 1.5)</code> should return <code>1</code> because it is greater than <code>1</code> (index 0), but less than <code>2</code> (index 1).",
"Likewise, <code>where([20,3,5], 19)</code> should return <code>2</code> because once the array has been sorted it will look like <code>[3,5,20]</code> and <code>19</code> is less than <code>20</code> (index 2) and greater than <code>5</code> (index 1).",
2015-08-27 06:23:46 +00: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."
2015-06-03 03:32:10 +00:00
],
"challengeSeed": [
"function where(arr, num) {",
" // Find my place in this sorted array.",
" return num;",
"}",
"",
"where([40, 60], 50);"
2015-06-03 03:32:10 +00:00
],
"MDNlinks": [
"Array.sort()"
],
"solutions": [
"function where(arr, num) {\n arr = arr.sort(function(a, b){return a-b;});\n for (var i = 0; i < arr.length; i++) {\n if (arr[i] >= num)\n {\n return i;\n }\n }\n return arr.length;\n}"
],
2015-06-03 03:32:10 +00:00
"tests": [
"assert(where([10, 20, 30, 40, 50], 35) === 3, 'message: <code>where([10, 20, 30, 40, 50], 35)</code> should return <code>3</code>.');",
"assert(where([10, 20, 30, 40, 50], 30) === 2, 'message: <code>where([10, 20, 30, 40, 50], 30)</code> should return <code>2</code>.');",
"assert(where([40, 60], 50) === 1, 'message: <code>where([40, 60], 50)</code> should return <code>1</code>.');",
"assert(where([3, 10, 5], 3) === 0, 'message: <code>where([3, 10, 5], 3)</code> should return <code>0</code>.');",
"assert(where([5, 3, 20, 3], 5) === 2, 'message: <code>where([5, 3, 20, 3], 5)</code> should return <code>2</code>.');",
"assert(where([2, 20, 10], 19) === 2, 'message: <code>where([2, 20, 10], 19)</code> should return <code>2</code>.');",
"assert(where([2, 5, 10], 15) === 3, 'message: <code>where([2, 5, 10], 15)</code> should return <code>3</code>.');"
2015-06-03 03:32:10 +00:00
],
2015-08-08 06:37:32 +00:00
"type": "bonfire",
2015-06-03 03:32:10 +00:00
"challengeType": 5,
"nameCn": "",
"descriptionCn": [],
"nameFr": "",
"descriptionFr": [],
"nameRu": "",
"descriptionRu": [],
2015-11-13 15:26:48 +00:00
"nameEs": "¿Cuál es mi asiento?",
"descriptionEs": [
"Devuelve el menor índice en el que un valor (segundo argumento) debe ser insertado en un arreglo ordenado (primer argumento).",
"Por ejemplo, where([1,2,3,4], 1.5) debe devolver 1 porque el segundo argumento de la función (1.5) es mayor que 1 (con índice 0 en el arreglo), pero menor que 2 (con índice 1).",
"Recuerda utilizar <a href='//github.com/FreeCodeCamp/freecodecamp/wiki/How-to-get-help-when-you-get-stuck' target='_blank'>Read-Search-Ask</a> si te sientes atascado. Intenta programar en pareja. Escribe tu propio código."
],
2015-06-03 03:32:10 +00:00
"namePt": "",
"descriptionPt": [],
"isRequired": true
2016-01-02 03:19:56 +00:00
},
{
"id": "56533eb9ac21ba0edf2244e2",
"title": "Caesar's Cipher",
"description": [
"One of the simplest and most widely known <dfn>ciphers</dfn> is a <code>Caesar cipher</code>, also known as a <code>shift cipher</code>. In a <code>shift cipher</code> the meanings of the letters are shifted by some set amount.",
"A common modern use is the <a href=\"https://en.wikipedia.org/wiki/ROT13\">ROT13</a> cipher, where the values of the letters are shifted by 13 places. Thus 'A' &harr; 'N', 'B' &harr; 'O' and so on.",
"Write a function which takes a <a href=\"https://en.wikipedia.org/wiki/ROT13\">ROT13</a> encoded string as input and returns a decoded string.",
"All letters will be uppercase. Do not transform any non-alphabetic character (i.e. spaces, punctuation), but do pass them on.",
"Remember to use <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. Try to pair program. Write your own code."
],
"MDNlinks": [
"String.charCodeAt()",
"String.fromCharCode()"
2016-01-02 03:19:56 +00:00
],
"releasedOn": "January 1, 2016",
"challengeSeed": [
"function rot13(str) { // LBH QVQ VG!",
" ",
" return str;",
2016-01-02 03:19:56 +00:00
"}",
"",
"// Change the inputs below to test",
"rot13(\"SERR PBQR PNZC\");"
],
"tail": [
""
],
"solutions": [
"var lookup = {\n 'A': 'N','B': 'O','C': 'P','D': 'Q',\n 'E': 'R','F': 'S','G': 'T','H': 'U',\n 'I': 'V','J': 'W','K': 'X','L': 'Y',\n 'M': 'Z','N': 'A','O': 'B','P': 'C',\n 'Q': 'D','R': 'E','S': 'F','T': 'G',\n 'U': 'H','V': 'I','W': 'J','X': 'K',\n 'Y': 'L','Z': 'M' \n};\n\nfunction rot13(encodedStr) {\n var codeArr = encodedStr.split(\"\"); // String to Array\n var decodedArr = []; // Your Result goes here\n // Only change code below this line\n \n decodedArr = codeArr.map(function(letter) {\n if(lookup.hasOwnProperty(letter)) {\n letter = lookup[letter];\n }\n return letter;\n });\n\n // Only change code above this line\n return decodedArr.join(\"\"); // Array to String\n}"
],
"tests": [
"assert(rot13(\"SERR PBQR PNZC\") === \"FREE CODE CAMP\", 'message: <code>rot13(\"SERR PBQR PNZC\")</code> should decode to <code>\"FREE CODE CAMP\"</code>');",
"assert(rot13(\"SERR CVMMN!\") === \"FREE PIZZA!\", 'message: <code>rot13(\"SERR CVMMN!\")</code> should decode to <code>\"FREE PIZZA!\"</code>');",
"assert(rot13(\"SERR YBIR?\") === \"FREE LOVE?\", 'message: <code>rot13(\"SERR YBIR?\")</code> should decode to <code>\"FREE LOVE?\"</code>');",
"assert(rot13(\"GUR DHVPX OEBJA QBT WHZCRQ BIRE GUR YNML SBK.\") === \"THE QUICK BROWN DOG JUMPED OVER THE LAZY FOX.\", 'message: <code>rot13(\"GUR DHVPX OEBJA QBT WHZCRQ BIRE GUR YNML SBK.\")</code> should decode to <code>\"THE QUICK BROWN DOG JUMPED OVER THE LAZY FOX.\"</code>');"
],
"type": "bonfire",
"challengeType": "5",
"nameCn": "",
"nameFr": "",
"nameRu": "",
"nameEs": "",
"namePt": "",
"isRequired": true
2015-06-03 03:32:10 +00:00
}
]
}