949 lines
61 KiB
JSON
949 lines
61 KiB
JSON
{
|
|
"name": "Basic Algorithm Scripting",
|
|
"order": 5,
|
|
"time": "50 hours",
|
|
"helpRoom": "HelpJavaScript",
|
|
"challenges": [
|
|
{
|
|
"id": "bd7158d2c442eddfbeb5bd1f",
|
|
"title": "Get Set for our Algorithm Challenges",
|
|
"description": [
|
|
[
|
|
"//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.",
|
|
""
|
|
],
|
|
[
|
|
"//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.",
|
|
""
|
|
],
|
|
[
|
|
"//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.",
|
|
""
|
|
],
|
|
[
|
|
"//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.",
|
|
""
|
|
]
|
|
],
|
|
"challengeSeed": [],
|
|
"tests": [],
|
|
"type": "Waypoint",
|
|
"challengeType": 7,
|
|
"isRequired": false,
|
|
"translations": {
|
|
"es": {
|
|
"title": "Prepárate para nuestros Desafíos sobre Algoritmos",
|
|
"description": [
|
|
[
|
|
"//i.imgur.com/sJkp30a.png",
|
|
"Una imagen de un desafio sobre algoritmos que presenta instrucciones, pruebas y el editor de código.",
|
|
"Nuestros desafios sobre algoritmos te enseñarán como pensar como un programador.",
|
|
""
|
|
],
|
|
[
|
|
"//i.imgur.com/d8LuRNh.png",
|
|
"Una mamá pájaro saca un bebé pájaro fuer de su nido.",
|
|
"Nuestros desafios anteriores te introdujeron a los conceptos de programación. Pero para estos desafios sobre algoritmos, ahora necesitarás aplicar lo que has aprendido y resolver problemas de respuesta abierta",
|
|
""
|
|
],
|
|
[
|
|
"//i.imgur.com/WBetuBa.jpg",
|
|
"Un programador frustado golpeando la pantalla de su computador.",
|
|
"Nuestros desafíos sobre algortimos son difíciles. Algunos pueden requerir muchas horas para resolverse. Podrás frustarte, pero no te rindas.",
|
|
""
|
|
],
|
|
[
|
|
"//i.imgur.com/p2TpOQd.jpg",
|
|
"Un tierno perro que salta sobre un obstáculo, pica el ojo y te apunta con su pata.",
|
|
"Cuando te atasques, usa la metodología Leer-Buscar-Preguntar.<br>No te preocupes - ya lo has entendido.",
|
|
""
|
|
]
|
|
]
|
|
},
|
|
"pt-br": {
|
|
"title": "Prepare-se para os Desafios de Algoritmos",
|
|
"description": [
|
|
[
|
|
"//i.imgur.com/sJkp30a.png",
|
|
"Uma imagem de um desagio de algoritmo mostrando direções, testes e o editor de código.",
|
|
"Nossos desafios de algoritmos vão ensinar você como pensar como um programador.",
|
|
""
|
|
],
|
|
[
|
|
"//i.imgur.com/d8LuRNh.png",
|
|
"Uma mãe pássaro chuta um bebê para fora do ninho.",
|
|
"Nossos desafios anteriores introduziram você aos conceitos de programação. Mas para esses desafios de algoritmos, agora você vai precisar aplicar o que você aprendeu para resolver problemas abertos.",
|
|
""
|
|
],
|
|
[
|
|
"//i.imgur.com/WBetuBa.jpg",
|
|
"Um programador atravessando a tela de seu laptop com um soco em frustração.",
|
|
"Nossos desafios de algoritmos são difíceis. Alguns deles podem levar algumas horas para resolver. Você vai ficar frustrado. Mas não desista.",
|
|
""
|
|
],
|
|
[
|
|
"//i.imgur.com/p2TpOQd.jpg",
|
|
"Um cachorro fofo pulando sobre um obstáculo, piscando e apontando sua pata à você.",
|
|
"Quendo você ficar travado, use a metodoloia Ler-Pesquisar-Perguntar.<br>Não se preocupe - você consegue.",
|
|
""
|
|
]
|
|
]
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"id": "56533eb9ac21ba0edf2244b3",
|
|
"title": "Convert Celsius to Fahrenheit",
|
|
"description": [
|
|
"The algorithm to convert from Celsius to Fahrenheit is the temperature in Celsius times <code>9/5</code>, plus <code>32</code>.",
|
|
"You are given a variable <code>celsius</code> representing a temperature in Celsius. Use the variable <code>fahrenheit</code> already defined and apply the algorithm to assign it the corresponding temperature in Fahrenheit."
|
|
],
|
|
"releasedOn": "January 1, 2016",
|
|
"challengeSeed": [
|
|
"function convertToF(celsius) {",
|
|
" var fahrenheit;",
|
|
" return fahrenheit;",
|
|
"}",
|
|
"",
|
|
"convertToF(30);"
|
|
],
|
|
"solutions": [
|
|
"function convertToF(celsius) {\n var fahrenheit = celsius * 9/5 + 32;\n if ( typeof fahrenheit !== 'undefined' ) {\n return fahrenheit;\n } else {\n return 'fahrenheit not defined';\n }\n}"
|
|
],
|
|
"tests": [
|
|
"assert(typeof convertToF(0) === 'number', 'message: <code>convertToF(0)</code> should return a number');",
|
|
"assert(convertToF(-30) === -22, 'message: <code>convertToF(-30)</code> should return a value of <code>-22</code>');",
|
|
"assert(convertToF(-10) === 14, 'message: <code>convertToF(-10)</code> should return a value of <code>14</code>');",
|
|
"assert(convertToF(0) === 32, 'message: <code>convertToF(0)</code> should return a value of <code>32</code>');",
|
|
"assert(convertToF(20) === 68, 'message: <code>convertToF(20)</code> should return a value of <code>68</code>');",
|
|
"assert(convertToF(30) === 86, 'message: <code>convertToF(30)</code> should return a value of <code>86</code>');"
|
|
],
|
|
"type": "checkpoint",
|
|
"challengeType": 1,
|
|
"isRequired": true,
|
|
"translations": {
|
|
"es": {
|
|
"title": "Convierte celsius a fahrenheit",
|
|
"description": [
|
|
"Para probar tu aprendizaje, crearás una solucion \"desde cero\". Coloca tu código entre las líneas indicadas y este será probado contra multiples casos de prueba.",
|
|
"El algoritmo para convertir de Celsius a Fahrenheit consiste en multiplicar la temperatura en grados Celsius por 9/5 y al resultado agregarle 32.",
|
|
"Se te da una variable <code>celsius</code> representando una temperatura en Celsius. Crea una variable <code>fahrenheit</code> y aplica el algoritmo para asignar la correspondiente temperatura en Fahrenheit."
|
|
]
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"id": "a202eed8fc186c8434cb6d61",
|
|
"title": "Reverse a String",
|
|
"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=\"http://forum.freeCodeCamp.com/t/how-to-get-help-when-you-are-stuck/19514\" target=\"_blank\">Read-Search-Ask</a> if you get stuck. Write your own code."
|
|
],
|
|
"challengeSeed": [
|
|
"function reverseString(str) {",
|
|
" return str;",
|
|
"}",
|
|
"",
|
|
"reverseString(\"hello\");"
|
|
],
|
|
"tests": [
|
|
"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>.');"
|
|
],
|
|
"type": "bonfire",
|
|
"isRequired": true,
|
|
"solutions": [
|
|
"function reverseString(str) {\n return str.split('').reverse().join(\"\");\n}\n\nreverseString('hello');\n"
|
|
],
|
|
"MDNlinks": [
|
|
"Global String Object",
|
|
"String.prototype.split()",
|
|
"Array.prototype.reverse()",
|
|
"Array.prototype.join()"
|
|
],
|
|
"challengeType": 5,
|
|
"translations": {
|
|
"es": {
|
|
"title": "Invierte el texto",
|
|
"description": [
|
|
"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='http://forum.freeCodeCamp.com/t/how-to-get-help-when-you-are-stuck/19514' target='_blank'>Leer-Buscar-Preguntar</a> si te sientes atascado. Intenta programar en pareja. Escribe tu propio código."
|
|
]
|
|
},
|
|
"pt-br": {
|
|
"title": "Inverter um texto",
|
|
"description": [
|
|
"Inverta o texto fornecido.",
|
|
"Você pode precisar transformar o texto em uma matriz antes de poder invertê-lo.",
|
|
"Seu resultado deve ser um texto.",
|
|
"Lembre-se de usar <a href=\"http://forum.freeCodeCamp.com/t/how-to-get-help-when-you-are-stuck/19514\" target=\"_blank\">Ler-Pesquisar-Perguntar</a> se você ficar travado. Escreva seu próprio código."
|
|
]
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"id": "a302f7aae1aa3152a5b413bc",
|
|
"title": "Factorialize a Number",
|
|
"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.",
|
|
"Factorials are often represented with the shorthand notation <code>n!</code>",
|
|
"For example: <code>5! = 1 * 2 * 3 * 4 * 5 = 120</code>",
|
|
"Only integers greater than or equal to zero will be supplied to the function.",
|
|
"Remember to use <a href=\"http://forum.freeCodeCamp.com/t/how-to-get-help-when-you-are-stuck/19514\" target=\"_blank\">Read-Search-Ask</a> if you get stuck. Write your own code."
|
|
],
|
|
"challengeSeed": [
|
|
"function factorialize(num) {",
|
|
" return num;",
|
|
"}",
|
|
"",
|
|
"factorialize(5);"
|
|
],
|
|
"tests": [
|
|
"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.');"
|
|
],
|
|
"type": "bonfire",
|
|
"isRequired": true,
|
|
"solutions": [
|
|
"function factorialize(num) {\n return num < 1 ? 1 : num * factorialize(num-1);\n}\n\nfactorialize(5);\n"
|
|
],
|
|
"MDNlinks": [
|
|
"Arithmetic Operators"
|
|
],
|
|
"challengeType": 5,
|
|
"translations": {
|
|
"es": {
|
|
"title": "Factoriza un número",
|
|
"description": [
|
|
"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='http://forum.freeCodeCamp.com/t/how-to-get-help-when-you-are-stuck/19514' target='_blank'>Leer-Buscar-Preguntar</a> si te sientes atascado. Intenta programar en pareja. Escribe tu propio código."
|
|
]
|
|
},
|
|
"pt-br": {
|
|
"title": "Fatorial de um número",
|
|
"description": [
|
|
"Retorne o fatorial de um número inteiro fornecido.",
|
|
"Se o inteiro é representado pela letra n, o fatorial é o produto de todos os inteiros positivos menores ou iguais a n.",
|
|
"Fatoriais são comumente representados pela notação <code>n!</code>",
|
|
"Por exemplo: <code>5! = 1 * 2 * 3 * 4 * 5 = 120</code>",
|
|
"Apenas inteiros maior que ou iguais a zero serão fornecidos à função.",
|
|
"Lembre-se de usar <a href=\"http://forum.freeCodeCamp.com/t/how-to-get-help-when-you-are-stuck/19514\" target=\"_blank\">Ler-Pesquisar-Perguntar</a> se você ficar travado. Escreva seu próprio código."
|
|
]
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"id": "a26cbbe9ad8655a977e1ceb5",
|
|
"title": "Find the Longest Word in a String",
|
|
"description": [
|
|
"Return the length of the longest word in the provided sentence.",
|
|
"Your response should be a number.",
|
|
"Remember to use <a href=\"http://forum.freeCodeCamp.com/t/how-to-get-help-when-you-are-stuck/19514\" 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\");"
|
|
],
|
|
"tests": [
|
|
"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.');"
|
|
],
|
|
"type": "bonfire",
|
|
"isRequired": true,
|
|
"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"
|
|
],
|
|
"MDNlinks": [
|
|
"String.prototype.split()",
|
|
"String.length"
|
|
],
|
|
"challengeType": 5,
|
|
"translations": {
|
|
"es": {
|
|
"title": "Encuentra la palabra más larga",
|
|
"description": [
|
|
"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='http://forum.freeCodeCamp.com/t/how-to-get-help-when-you-are-stuck/19514' target='_blank'>Leer-Buscar-Preguntar</a> si te sientes atascado. Intenta programar en pareja. Escribe tu propio código."
|
|
]
|
|
},
|
|
"pt-br": {
|
|
"title": "Encontre a maior palavra num texto",
|
|
"description": [
|
|
"Retorne o tamanho da maior palavra na sentença fornecida.",
|
|
"Sua resposta deve ser um número.",
|
|
"Lembre-se de usar <a href=\"http://forum.freeCodeCamp.com/t/how-to-get-help-when-you-are-stuck/19514\" target=\"_blank\">Ler-Pesquisar-Perguntar</a> se você ficar travado. Escreva seu próprio código."
|
|
]
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"id": "a789b3483989747d63b0e427",
|
|
"title": "Return Largest Numbers in Arrays",
|
|
"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 <code>arr[i]</code>.",
|
|
"Remember to use <a href=\"http://forum.freeCodeCamp.com/t/how-to-get-help-when-you-are-stuck/19514\" 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([[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>.');",
|
|
"assert.deepEqual(largestOfFour([[17, 23, 25, 12], [25, 7, 34, 48], [4, -10, 18, 21], [-72, -3, -17, -10]]), [25, 48, 21, -3], 'message: <code>largestOfFour([[17, 23, 25, 12], [25, 7, 34, 48], [4, -10, 18, 21], [-72, -3, -17, -10]])</code> should return <code>[25, 48, 21, -3]</code>.');"
|
|
],
|
|
"type": "bonfire",
|
|
"isRequired": true,
|
|
"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"
|
|
],
|
|
"MDNlinks": [
|
|
"Comparison Operators"
|
|
],
|
|
"challengeType": 5,
|
|
"translations": {
|
|
"es": {
|
|
"title": "Devuelve el mayor entero de cada arreglo",
|
|
"description": [
|
|
"Crea una función que devuelva un arreglo que contenga el mayor de los números de cada sub-arreglo que recibe. Para simplificar las cosas, el arreglo que recibirá 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='http://forum.freeCodeCamp.com/t/how-to-get-help-when-you-are-stuck/19514' target='_blank'>Leer-Buscar-Preguntar</a> si te sientes atascado. Intenta programar en pareja. Escribe tu propio código."
|
|
]
|
|
},
|
|
"pt-br": {
|
|
"title": "Retorne os Maiores Números numa Matriz",
|
|
"description": [
|
|
"Retorne uma matriz que consiste no maior número de cada sub-matriz fornecida. Por simplicidade, a matriz fornecida conterá exatamente 4 sub-matrizes.",
|
|
"Lembre-se, você pode iterar sobre uma matriz com um simples laço for, e acesar cara membro com a sintaxe <code>arr[i]</code>.",
|
|
"Lembre-se de usar <a href=\"http://forum.freeCodeCamp.com/t/how-to-get-help-when-you-are-stuck/19514\" target=\"_blank\">Ler-Pesquisar-Perguntar</a> se você ficar travado. Escreva seu próprio código."
|
|
]
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"id": "acda2fb1324d9b0fa741e6b5",
|
|
"title": "Confirm the Ending",
|
|
"description": [
|
|
"Check if a string (first argument, <code>str</code>) ends with the given target string (second argument, <code>target</code>).",
|
|
"This challenge <em>can</em> be solved with the <code>.endsWith()</code> method, which was introduced in ES2015. But for the purpose of this challenge, we would like you to use one of the JavaScript substring methods instead.",
|
|
"Remember to use <a href=\"http://forum.freeCodeCamp.com/t/how-to-get-help-when-you-are-stuck/19514\" target=\"_blank\">Read-Search-Ask</a> if you get stuck. Write your own code."
|
|
],
|
|
"challengeSeed": [
|
|
"function confirmEnding(str, target) {",
|
|
" // \"Never give up and good luck will find you.\"",
|
|
" // -- Falcor",
|
|
" return str;",
|
|
"}",
|
|
"",
|
|
"confirmEnding(\"Bastian\", \"n\");"
|
|
],
|
|
"tests": [
|
|
"assert(confirmEnding(\"Bastian\", \"n\") === true, 'message: <code>confirmEnding(\"Bastian\", \"n\")</code> should return true.');",
|
|
"assert(confirmEnding(\"Connor\", \"n\") === false, 'message: <code>confirmEnding(\"Connor\", \"n\")</code> should return false.');",
|
|
"assert(confirmEnding(\"Walking on water and developing software from a specification are easy if both are frozen\", \"specification\") === false, 'message: <code>confirmEnding(\"Walking on water and developing software from a specification are easy if both are frozen\", \"specification\")</code> should return false.');",
|
|
"assert(confirmEnding(\"He has to give me a new name\", \"name\") === true, 'message: <code>confirmEnding(\"He has to give me a new name\", \"name\")</code> should return true.');",
|
|
"assert(confirmEnding(\"Open sesame\", \"same\") === true, 'message: <code>confirmEnding(\"Open sesame\", \"same\")</code> should return true.');",
|
|
"assert(confirmEnding(\"Open sesame\", \"pen\") === false, 'message: <code>confirmEnding(\"Open sesame\", \"pen\")</code> should return false.');",
|
|
"assert(confirmEnding(\"Open sesame\", \"game\") === false, 'message: <code>confirmEnding(\"Open sesame\", \"game\")</code> should return false.');",
|
|
"assert(confirmEnding(\"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>confirmEnding(\"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(confirmEnding(\"Abstraction\", \"action\") === true, 'message: <code>confirmEnding(\"Abstraction\", \"action\")</code> should return true.');",
|
|
"assert(!/\\.endsWith\\(.*?\\)\\s*?;?/.test(code), 'message: Do not use the built-in method <code>.endsWith()</code> to solve the challenge.');"
|
|
],
|
|
"type": "bonfire",
|
|
"isRequired": true,
|
|
"solutions": [
|
|
"function confirmEnding(str, target) {\n return str.substring(str.length-target.length) === target;\n};\n"
|
|
],
|
|
"MDNlinks": [
|
|
"String.prototype.substr()",
|
|
"String.prototype.substring()"
|
|
],
|
|
"challengeType": 5,
|
|
"translations": {
|
|
"es": {
|
|
"title": "Confirma la terminación",
|
|
"description": [
|
|
"Verifica si una cadena de texto (primer argumento) termina con otra cadena de texto (segundo argumento).",
|
|
"Recuerda utilizar <a href='http://forum.freeCodeCamp.com/t/how-to-get-help-when-you-are-stuck/19514' target='_blank'>Leer-Buscar-Preguntar</a> si te sientes atascado. Intenta programar en pareja. Escribe tu propio código."
|
|
]
|
|
},
|
|
"pt-br": {
|
|
"title": "Confirme o Fim",
|
|
"description": [
|
|
"Confira se um texto (primeiro argumento, <code>str</code>) termina com um texto alvo (segundo argumento, <code>target</code>).",
|
|
"Esse desafio <em>pode</em> ser resolvido com o método <code>.endsWith()</code>, que foi introduzido com o ES2015. Mas para o propósito deste desafio, nós gostaríamos que você usasse os métodos de substring do Javascript.",
|
|
"Lembre-se de usar <a href=\"http://forum.freeCodeCamp.com/t/how-to-get-help-when-you-are-stuck/19514\" target=\"_blank\">Ler-Pesquisar-Perguntar</a> se você ficar travado. Escreva seu próprio código."
|
|
]
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"id": "afcc8d540bea9ea2669306b6",
|
|
"title": "Repeat a String Repeat a String",
|
|
"description": [
|
|
"Repeat a given string <code>str</code> (first argument) for <code>num</code> times (second argument). Return an empty string if <code>num</code> is not a positive number.",
|
|
"Remember to use <a href=\"http://forum.freeCodeCamp.com/t/how-to-get-help-when-you-are-stuck/19514\" target=\"_blank\">Read-Search-Ask</a> if you get stuck. Write your own code."
|
|
],
|
|
"challengeSeed": [
|
|
"function repeatStringNumTimes(str, num) {",
|
|
" // repeat after me",
|
|
" return str;",
|
|
"}",
|
|
"",
|
|
"repeatStringNumTimes(\"abc\", 3);"
|
|
],
|
|
"tests": [
|
|
"assert(repeatStringNumTimes(\"*\", 3) === \"***\", 'message: <code>repeatStringNumTimes(\"*\", 3)</code> should return <code>\"***\"</code>.');",
|
|
"assert(repeatStringNumTimes(\"abc\", 3) === \"abcabcabc\", 'message: <code>repeatStringNumTimes(\"abc\", 3)</code> should return <code>\"abcabcabc\"</code>.');",
|
|
"assert(repeatStringNumTimes(\"abc\", 4) === \"abcabcabcabc\", 'message: <code>repeatStringNumTimes(\"abc\", 4)</code> should return <code>\"abcabcabcabc\"</code>.');",
|
|
"assert(repeatStringNumTimes(\"abc\", 1) === \"abc\", 'message: <code>repeatStringNumTimes(\"abc\", 1)</code> should return <code>\"abc\"</code>.');",
|
|
"assert(repeatStringNumTimes(\"*\", 8) === \"********\", 'message: <code>repeatStringNumTimes(\"*\", 8)</code> should return <code>\"********\"</code>.');",
|
|
"assert(repeatStringNumTimes(\"abc\", -2) === \"\", 'message: <code>repeatStringNumTimes(\"abc\", -2)</code> should return <code>\"\"</code>.');",
|
|
"assert(!/\\.repeat/g.test(code), 'message: The built-in <code>repeat()</code>-method should not be used');"
|
|
],
|
|
"type": "bonfire",
|
|
"isRequired": true,
|
|
"solutions": [
|
|
"function repeatStringNumTimes(str, num) {\n if (num < 0) return '';\n return num === 1 ? str : str + repeatStringNumTimes(str, num-1);\n}\n\nrepeatStringNumTimes('abc', 3);\n"
|
|
],
|
|
"MDNlinks": [
|
|
"Global String Object"
|
|
],
|
|
"challengeType": 5,
|
|
"translations": {
|
|
"es": {
|
|
"title": "Repite el Texto Repite el Texto",
|
|
"description": [
|
|
"Repite una cadena de texto dada (primer argumento) <code>num</code> veces (segundo argumento). Retorna una cadena de texto vacía si <code>num</code> es un número negativo.",
|
|
"Recuerda utilizar <a href='http://forum.freeCodeCamp.com/t/how-to-get-help-when-you-are-stuck/19514' target='_blank'>Leer-Buscar-Preguntar</a> si te sientes atascado. Intenta programar en pareja. Escribe tu propio código."
|
|
]
|
|
},
|
|
"pt-br": {
|
|
"title": "Repita o Texto Repita o Texto",
|
|
"description": [
|
|
"Repita o texto dado <code>str</code> (primeiro argumento) <code>num</code> vezes (segundo argumento). Retorne um texto vazio se <code>num</code> não é for um número positivo.",
|
|
"Lembre-se de usar <a href=\"http://forum.freeCodeCamp.com/t/how-to-get-help-when-you-are-stuck/19514\" target=\"_blank\">Ler-Pesquisar-Perguntar</a> se você ficar travado. Escreva seu próprio código."
|
|
]
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"id": "ac6993d51946422351508a41",
|
|
"title": "Truncate a String",
|
|
"description": [
|
|
"Truncate a string (first argument) if it is longer than the given maximum string length (second argument). Return the truncated string with a <code>...</code> ending.",
|
|
"Remember to use <a href=\"http://forum.freeCodeCamp.com/t/how-to-get-help-when-you-are-stuck/19514\" target=\"_blank\">Read-Search-Ask</a> if you get stuck. Write your own code."
|
|
],
|
|
"challengeSeed": [
|
|
"function truncateString(str, num) {",
|
|
" // Clear out that junk in your trunk",
|
|
" return str;",
|
|
"}",
|
|
"",
|
|
"truncateString(\"A-tisket a-tasket A green and yellow basket\", 8);"
|
|
],
|
|
"tests": [
|
|
"assert(truncateString(\"A-tisket a-tasket A green and yellow basket\", 8) === \"A-tisket...\", 'message: <code>truncateString(\"A-tisket a-tasket A green and yellow basket\", 8)</code> should return \"A-tisket...\".');",
|
|
"assert(truncateString(\"Peter Piper picked a peck of pickled peppers\", 11) === \"Peter Piper...\", 'message: <code>truncateString(\"Peter Piper picked a peck of pickled peppers\", 11)</code> should return \"Peter Piper...\".');",
|
|
"assert(truncateString(\"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>truncateString(\"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(truncateString('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>truncateString(\"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(truncateString(\"A-\", 1) === \"A...\", 'message: <code>truncateString(\"A-\", 1)</code> should return \"A...\".');",
|
|
"assert(truncateString(\"Absolutely Longer\", 2) === \"Ab...\", 'message: <code>truncateString(\"Absolutely Longer\", 2)</code> should return \"Ab...\".');"
|
|
],
|
|
"type": "bonfire",
|
|
"isRequired": true,
|
|
"solutions": [
|
|
"function truncateString(str, num) {\n if (num >= str.length) {\n return str;\n }\n return str.slice(0, num) + '...';\n}"
|
|
],
|
|
"MDNlinks": [
|
|
"String.prototype.slice()"
|
|
],
|
|
"challengeType": 5,
|
|
"translations": {
|
|
"es": {
|
|
"title": "Trunca una Cadena de Texto",
|
|
"description": [
|
|
"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 \"...\".",
|
|
"Recuerda utilizar <a href='http://forum.freeCodeCamp.com/t/how-to-get-help-when-you-are-stuck/19514' target='_blank'>Leer-Buscar-Preguntar</a> si te sientes atascado. Intenta programar en pareja. Escribe tu propio código."
|
|
]
|
|
},
|
|
"pt-br": {
|
|
"title": "Trunque um Texto",
|
|
"description": [
|
|
"Trunque um texto (primeiro argumento) se ela for mais longa que o comprimento máximo fornecido (segundo argumento). Retorne o texto truncada com <code>...</code> no final.",
|
|
"Lembre-se de usar <a href=\"http://forum.freeCodeCamp.com/t/how-to-get-help-when-you-are-stuck/19514\" target=\"_blank\">Ler-Pesquisar-Perguntar</a> se você ficar travado. Escreva seu próprio código."
|
|
]
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"id": "a6e40f1041b06c996f7b2406",
|
|
"title": "Finders Keepers",
|
|
"description": [
|
|
"Create a function that looks through an array (first argument) and returns the first element in the array that passes a truth test (second argument). If no element passes the test, return undefined.",
|
|
"Remember to use <a href='http://forum.freeCodeCamp.com/t/how-to-get-help-when-you-are-stuck/19514' target='_blank'>Read-Search-Ask</a> if you get stuck. Try to pair program. Write your own code."
|
|
],
|
|
"challengeSeed": [
|
|
"function findElement(arr, func) {",
|
|
" var num = 0;",
|
|
" return num;",
|
|
"}",
|
|
"",
|
|
"findElement([1, 2, 3, 4], function(num){ return num % 2 === 0; });"
|
|
],
|
|
"solutions": [
|
|
"function findElement(arr, func) {\n var num;\n arr.some(function(e) {\n if (func(e)) {\n num = e;\n return true;\n }\n });\n return num;\n}"
|
|
],
|
|
"tests": [
|
|
"assert.strictEqual(findElement([1, 3, 5, 8, 9, 10], function(num) { return num % 2 === 0; }), 8, 'message: <code>findElement([1, 3, 5, 8, 9, 10], function(num) { return num % 2 === 0; })</code> should return 8.');",
|
|
"assert.strictEqual(findElement([1, 3, 5, 9], function(num) { return num % 2 === 0; }), undefined, 'message: <code>findElement([1, 3, 5, 9], function(num) { return num % 2 === 0; })</code> should return undefined.');"
|
|
],
|
|
"type": "bonfire",
|
|
"MDNlinks": [
|
|
"Array.prototype.filter()"
|
|
],
|
|
"isRequired": true,
|
|
"challengeType": 5,
|
|
"translations": {
|
|
"es": {
|
|
"title": "Buscando la verdad",
|
|
"description": [
|
|
"Crea una función que busque dentro de un vector (primer argumento) y que devuelva el primer elemento que pase una prueba de verdad (segundo argumento).",
|
|
"Recuerda utilizar <a href='http://forum.freeCodeCamp.com/t/how-to-get-help-when-you-are-stuck/19514' target='_blank'>Leer-Buscar-Preguntar</a> si te sientes atascado. Intenta programar en pareja. Escribe tu propio código."
|
|
]
|
|
},
|
|
"fr": {
|
|
"title": "Détecteur de mensonges",
|
|
"description": [
|
|
"Crée une fonction qui parcourt un tableau (premier argument) et renvoie le premier élément du tableau qui passe le test (second argument).",
|
|
"N'oublie pas d'utiliser <a href='http://forum.freeCodeCamp.com/t/how-to-get-help-when-you-are-stuck/19514' target='_blank'>Lire-Chercher-Demander</a> si tu es bloqué. Essaye de trouver un partenaire. Écris ton propre code."
|
|
]
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"id": "a77dbc43c33f39daa4429b4f",
|
|
"title": "Boo who",
|
|
"description": [
|
|
"Check if a value is classified as a boolean primitive. Return true or false.",
|
|
"Boolean primitives are true and false.",
|
|
"Remember to use <a href='http://forum.freeCodeCamp.com/t/how-to-get-help-when-you-are-stuck/19514' target='_blank'>Read-Search-Ask</a> if you get stuck. Try to pair program. Write your own code."
|
|
],
|
|
"challengeSeed": [
|
|
"function booWho(bool) {",
|
|
" // What is the new fad diet for ghost developers? The Boolean.",
|
|
" return bool;",
|
|
"}",
|
|
"",
|
|
"booWho(null);"
|
|
],
|
|
"solutions": [
|
|
"function booWho(bool) {\n // What is the new fad diet for ghost developers? The Boolean.\n return typeof bool === \"boolean\";\n}\n\nbooWho(null);"
|
|
],
|
|
"tests": [
|
|
"assert.strictEqual(booWho(true), true, 'message: <code>booWho(true)</code> should return true.');",
|
|
"assert.strictEqual(booWho(false), true, 'message: <code>booWho(false)</code> should return true.');",
|
|
"assert.strictEqual(booWho([1, 2, 3]), false, 'message: <code>booWho([1, 2, 3])</code> should return false.');",
|
|
"assert.strictEqual(booWho([].slice), false, 'message: <code>booWho([].slice)</code> should return false.');",
|
|
"assert.strictEqual(booWho({ \"a\": 1 }), false, 'message: <code>booWho({ \"a\": 1 })</code> should return false.');",
|
|
"assert.strictEqual(booWho(1), false, 'message: <code>booWho(1)</code> should return false.');",
|
|
"assert.strictEqual(booWho(NaN), false, 'message: <code>booWho(NaN)</code> should return false.');",
|
|
"assert.strictEqual(booWho(\"a\"), false, 'message: <code>booWho(\"a\")</code> should return false.');",
|
|
"assert.strictEqual(booWho(\"true\"), false, 'message: <code>booWho(\"true\")</code> should return false.');",
|
|
"assert.strictEqual(booWho(\"false\"), false, 'message: <code>booWho(\"false\")</code> should return false.');"
|
|
],
|
|
"type": "bonfire",
|
|
"MDNlinks": [
|
|
"Boolean Objects"
|
|
],
|
|
"isRequired": true,
|
|
"challengeType": 5,
|
|
"translations": {
|
|
"es": {
|
|
"title": "¡Bu!",
|
|
"description": [
|
|
"Crea una función que verifique si el valor que se le pasa es de tipo booleano. Haz que la función devuelva true o false según corresponda.",
|
|
"Los primitivos booleanos primitivos son: true y false",
|
|
"Recuerda utilizar <a href='http://forum.freeCodeCamp.com/t/how-to-get-help-when-you-are-stuck/19514' target='_blank'>Leer-Buscar-Preguntar</a> si te sientes atascado. Intenta programar en pareja. Escribe tu propio código."
|
|
]
|
|
},
|
|
"fr": {
|
|
"title": "Boo !",
|
|
"description": [
|
|
"Crée une fonction qui vérifie qu'une valeur est de type booléen. Renvoie true ou false.",
|
|
"Les primitives booléennes sont true ou false.",
|
|
"N'oublie pas d'utiliser <a href='http://forum.freeCodeCamp.com/t/how-to-get-help-when-you-are-stuck/19514' target='_blank'>Lire-Chercher-Demander</a> si tu es bloqué. Essaye de trouver un partenaire. Écris ton propre code."
|
|
]
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"id": "ab6137d4e35944e21037b769",
|
|
"title": "Title Case a Sentence",
|
|
"description": [
|
|
"Return the provided string with the first letter of each word capitalized. Make sure the rest of the word is in lower case.",
|
|
"For the purpose of this exercise, you should also capitalize connecting words like \"the\" and \"of\".",
|
|
"Remember to use <a href=\"http://forum.freeCodeCamp.com/t/how-to-get-help-when-you-are-stuck/19514\" 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\");"
|
|
],
|
|
"tests": [
|
|
"assert(typeof titleCase(\"I'm a little tea pot\") === \"string\", 'message: <code>titleCase(\"I'm a little tea pot\")</code> should return a string.');",
|
|
"assert(titleCase(\"I'm a little tea pot\") === \"I'm A Little Tea Pot\", 'message: <code>titleCase(\"I'm a little tea pot\")</code> should return \"I'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\".');"
|
|
],
|
|
"type": "bonfire",
|
|
"isRequired": true,
|
|
"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"
|
|
],
|
|
"MDNlinks": [
|
|
"String.prototype.split()"
|
|
],
|
|
"challengeType": 5,
|
|
"translations": {
|
|
"es": {
|
|
"title": "Aplica formato de título",
|
|
"description": [
|
|
"Crea una función que devuelva la cadena de texto que recibe 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='http://forum.freeCodeCamp.com/t/how-to-get-help-when-you-are-stuck/19514' target='_blank'>Leer-Buscar-Preguntar</a> si te sientes atascado. Intenta programar en pareja. Escribe tu propio código."
|
|
]
|
|
},
|
|
"pt-br": {
|
|
"title": "Transforme o Texto em um Título",
|
|
"description": [
|
|
"Retorne o texto fornecido com a primeira letra de cada palavra em maiúsculo. Garanta que o resto da palavra esteja em formato minúsculo.",
|
|
"Para o propósito deste exercício, você deve transformar também palavras conectivas como \"the\" e \"of\".",
|
|
"Lembre-se de usar <a href=\"http://forum.freeCodeCamp.com/t/how-to-get-help-when-you-are-stuck/19514\" target=\"_blank\">Ler-Pesquisar-Perguntar</a> se você ficar travado. Escreva seu próprio código."
|
|
]
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"id": "579e2a2c335b9d72dd32e05c",
|
|
"title": "Slice and Splice",
|
|
"description": [
|
|
"You are given two arrays and an index.",
|
|
"Use the array methods <code>slice</code> and <code>splice</code> to copy each element of the first array into the second array, in order.",
|
|
"Begin inserting elements at index <code>n</code> of the second array.",
|
|
"Return the resulting array. The input arrays should remain the same after the function runs.",
|
|
"Remember to use <a href=\"http://forum.freeCodeCamp.com/t/how-to-get-help-when-you-are-stuck/19514\" target=\"_blank\">Read-Search-Ask</a> if you get stuck. Write your own code."
|
|
],
|
|
"challengeSeed": [
|
|
"function frankenSplice(arr1, arr2, n) {",
|
|
" // It's alive. It's alive!",
|
|
" return arr2;",
|
|
"}",
|
|
"",
|
|
"frankenSplice([1, 2, 3], [4, 5, 6], 1);"
|
|
],
|
|
"tail": [
|
|
"var testArr1 = [1, 2];",
|
|
"var testArr2 = ['a', 'b'];"
|
|
],
|
|
"tests": [
|
|
"assert.deepEqual(frankenSplice([1, 2, 3], [4, 5], 1), [4, 1, 2, 3, 5], 'message: <code>frankenSplice([1, 2, 3], [4, 5], 1)</code> should return <code>[4, 1, 2, 3, 5]</code>.');",
|
|
"assert.deepEqual(frankenSplice(testArr1, testArr2, 1), ['a', 1, 2, 'b'], 'message: <code>frankenSplice([1, 2], [\"a\", \"b\"], 1)</code> should return <code>[\"a\", 1, 2, \"b\"]</code>.');",
|
|
"assert.deepEqual(frankenSplice(['claw', 'tentacle'], ['head', 'shoulders', 'knees', 'toes'], 2), ['head', 'shoulders', 'claw', 'tentacle', 'knees', 'toes'], 'message: <code>frankenSplice([\"claw\", \"tentacle\"], [\"head\", \"shoulders\", \"knees\", \"toes\"], 2)</code> should return <code>[\"head\", \"shoulders\", \"claw\", \"tentacle\", \"knees\", \"toes\"]</code>.');",
|
|
"assert.deepEqual(frankenSplice([1, 2, 3, 4], [], 0), [1, 2, 3, 4], 'message: All elements from the first array should be added to the second array in their original order.');",
|
|
"assert(testArr1[0] === 1 && testArr1[1] === 2, 'message: The first array should remain the same after the function runs.');",
|
|
"assert(testArr2[0] === 'a' && testArr2[1] === 'b', 'message: The second array should remain the same after the function runs.');"
|
|
],
|
|
"type": "bonfire",
|
|
"isRequired": true,
|
|
"isBeta": true,
|
|
"solutions": [
|
|
"function frankenSplice(arr1, arr2, n) {\n // It's alive. It's alive!\n var result = arr2.slice();\n for(var i = 0; i < arr1.length; i++) {\n result.splice(n+i, 0, arr1[i]);\n }\n return result;\n}\n\nfrankenSplice([1, 2, 3], [4, 5], 1);\n"
|
|
],
|
|
"MDNlinks": [
|
|
"Array.prototype.slice()",
|
|
"Array.prototype.splice()"
|
|
],
|
|
"challengeType": 5,
|
|
"translations": {
|
|
"pt-br": {
|
|
"title": "Slice e Splice",
|
|
"description": [
|
|
"É dado a você duas matrizes e um índice.",
|
|
"Use os métodos de matrizes <code>slice</code> e <code>splice</code> para copiar cada elemento da primeira matriz e colocar na segunda matriz, na ordem.",
|
|
"Comece a inserir elementos no índice <code>n</code> da segunda matriz.",
|
|
"Retorne a matriz resultante. As matrizes fornecidas devem permanecer inalteradas após a função ser executada.",
|
|
"Lembre-se de usar <a href=\"http://forum.freeCodeCamp.com/t/how-to-get-help-when-you-are-stuck/19514\" target=\"_blank\">Ler-Pesquisar-Perguntar</a> se você ficar travado. Escreva seu próprio código."
|
|
]
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"id": "adf08ec01beb4f99fc7a68f2",
|
|
"title": "Falsy Bouncer",
|
|
"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>.",
|
|
"Hint: Try converting each value to a Boolean.",
|
|
"Remember to use <a href=\"http://forum.freeCodeCamp.com/t/how-to-get-help-when-you-are-stuck/19514\" 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;",
|
|
"}",
|
|
"",
|
|
"bouncer([7, \"ate\", \"\", false, 9]);"
|
|
],
|
|
"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>.');",
|
|
"assert.deepEqual(bouncer([1, null, NaN, 2, undefined]), [1, 2], 'message: <code>bouncer([1, null, NaN, 2, undefined])</code> should return <code>[1, 2]</code>.');"
|
|
],
|
|
"type": "bonfire",
|
|
"isRequired": true,
|
|
"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"
|
|
],
|
|
"MDNlinks": [
|
|
"Boolean Objects",
|
|
"Array.prototype.filter()"
|
|
],
|
|
"challengeType": 5,
|
|
"translations": {
|
|
"es": {
|
|
"title": "Detector de Mentiras",
|
|
"description": [
|
|
"Remueve todos los valores falsy de un arreglo dado",
|
|
"En javascript, los 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='http://forum.freeCodeCamp.com/t/how-to-get-help-when-you-are-stuck/19514' target='_blank'>Leer-Buscar-Preguntar</a> si te sientes atascado. Intenta programar en pareja. Escribe tu propio código."
|
|
]
|
|
},
|
|
"pt-br": {
|
|
"title": "Detector de Mentiras",
|
|
"description": [
|
|
"Remova todos os valores falsos de uma matriz.",
|
|
"Valores falsos em JavaScript são <code>false</code>, <code>null</code>, <code>0</code>, <code>\"\"</code>, <code>undefined</code>, e <code>NaN</code>.",
|
|
"Lembre-se de usar <a href=\"http://forum.freeCodeCamp.com/t/how-to-get-help-when-you-are-stuck/19514\" target=\"_blank\">Ler-Pesquisar-Perguntar</a> se você ficar travado. Escreva seu próprio código."
|
|
]
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"id": "a24c1a4622e3c05097f71d67",
|
|
"title": "Where do I Belong",
|
|
"description": [
|
|
"Return the lowest index at which a value (second argument) should be inserted into an array (first argument) once it has been sorted. The returned value should be a number.",
|
|
"For example, <code>getIndexToIns([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>getIndexToIns([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).",
|
|
"Remember to use <a href=\"http://forum.freeCodeCamp.com/t/how-to-get-help-when-you-are-stuck/19514\" target=\"_blank\">Read-Search-Ask</a> if you get stuck. Write your own code."
|
|
],
|
|
"challengeSeed": [
|
|
"function getIndexToIns(arr, num) {",
|
|
" // Find my place in this sorted array.",
|
|
" return num;",
|
|
"}",
|
|
"",
|
|
"getIndexToIns([40, 60], 50);"
|
|
],
|
|
"tests": [
|
|
"assert(getIndexToIns([10, 20, 30, 40, 50], 35) === 3, 'message: <code>getIndexToIns([10, 20, 30, 40, 50], 35)</code> should return <code>3</code>.');",
|
|
"assert(typeof(getIndexToIns([10, 20, 30, 40, 50], 35)) === \"number\", 'message: <code>getIndexToIns([10, 20, 30, 40, 50], 35)</code> should return a number.');",
|
|
"assert(getIndexToIns([10, 20, 30, 40, 50], 30) === 2, 'message: <code>getIndexToIns([10, 20, 30, 40, 50], 30)</code> should return <code>2</code>.');",
|
|
"assert(typeof(getIndexToIns([10, 20, 30, 40, 50], 30)) === \"number\", 'message: <code>getIndexToIns([10, 20, 30, 40, 50], 30)</code> should return a number.');",
|
|
"assert(getIndexToIns([40, 60], 50) === 1, 'message: <code>getIndexToIns([40, 60], 50)</code> should return <code>1</code>.');",
|
|
"assert(typeof(getIndexToIns([40, 60], 50)) === \"number\", 'message: <code>getIndexToIns([40, 60], 50)</code> should return a number.');",
|
|
"assert(getIndexToIns([3, 10, 5], 3) === 0, 'message: <code>getIndexToIns([3, 10, 5], 3)</code> should return <code>0</code>.');",
|
|
"assert(typeof(getIndexToIns([3, 10, 5], 3)) === \"number\", 'message: <code>getIndexToIns([3, 10, 5], 3)</code> should return a number.');",
|
|
"assert(getIndexToIns([5, 3, 20, 3], 5) === 2, 'message: <code>getIndexToIns([5, 3, 20, 3], 5)</code> should return <code>2</code>.');",
|
|
"assert(typeof(getIndexToIns([5, 3, 20, 3], 5)) === \"number\", 'message: <code>getIndexToIns([5, 3, 20, 3], 5)</code> should return a number.');",
|
|
"assert(getIndexToIns([2, 20, 10], 19) === 2, 'message: <code>getIndexToIns([2, 20, 10], 19)</code> should return <code>2</code>.');",
|
|
"assert(typeof(getIndexToIns([2, 20, 10], 19)) === \"number\", 'message: <code>getIndexToIns([2, 20, 10], 19)</code> should return a number.');",
|
|
"assert(getIndexToIns([2, 5, 10], 15) === 3, 'message: <code>getIndexToIns([2, 5, 10], 15)</code> should return <code>3</code>.');",
|
|
"assert(typeof(getIndexToIns([2, 5, 10], 15)) === \"number\", 'message: <code>getIndexToIns([2, 5, 10], 15)</code> should return a number.');",
|
|
"assert(getIndexToIns([], 1) === 0, 'message: <code>getIndexToIns([], 1)</code> should return <code>0</code>.');",
|
|
"assert(typeof(getIndexToIns([], 1)) === \"number\", 'message: <code>getIndexToIns([], 1)</code> should return a number.');"
|
|
],
|
|
"type": "bonfire",
|
|
"isRequired": true,
|
|
"solutions": [
|
|
"function getIndexToIns(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}"
|
|
],
|
|
"MDNlinks": [
|
|
"Array.prototype.sort()"
|
|
],
|
|
"challengeType": 5,
|
|
"translations": {
|
|
"es": {
|
|
"title": "¿Cuál es mi Asiento?",
|
|
"description": [
|
|
"Devuelve el menor índice en el que un valor (segundo argumento) debe ser insertado en un arreglo (primer argumento) una vez ha sido ordenado.",
|
|
"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).",
|
|
"Mientras que <code>where([20,3,5], 19)</code> debe devolver <code>2</code> porque una vez ordenado el arreglo se verá com <code>[3,5,20]</code> y <code>19</code> es menor que <code>20</code> (índice 2) y mayor que <code>5</code> (índice 1).",
|
|
"Recuerda utilizar <a href='http://forum.freeCodeCamp.com/t/how-to-get-help-when-you-are-stuck/19514' target='_blank'>Leer-Buscar-Preguntar</a> si te sientes atascado. Intenta programar en pareja. Escribe tu propio código."
|
|
]
|
|
},
|
|
"pt-br": {
|
|
"title": "Qual o Meu Lugar?",
|
|
"description": [
|
|
"Retorne o menor índice que um valor (segundo argumento) deve ser inserido em uma matriz (primeiro argumento) uma vez que esta foi ordenada. O valor retornado deve ser um número.",
|
|
"Por exemplo, <code>getIndexToIns([1,2,3,4], 1.5)</code> deve retornar <code>1</code> porque é maior do que <code>1</code> (índice 0), mas é menor que <code>2</code> (índice 1).",
|
|
"Da mesma forma, <code>getIndexToIns([20,3,5], 19)</code> deve retornar <code>2</code> porque uma vez que a matriz foi ordenada ficará da seguinte forma <code>[3,5,20]</code> e <code>19</code> é menor que <code>20</code> (índice 2) e maior que <code>5</code> (índice 1).",
|
|
"Lembre-se de usar <a href=\"http://forum.freeCodeCamp.com/t/how-to-get-help-when-you-are-stuck/19514\" target=\"_blank\">Ler-Pesquisar-Perguntar</a> se você ficar travado. Escreva seu próprio código."
|
|
]
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"id": "af2170cad53daa0770fabdea",
|
|
"title": "Mutations",
|
|
"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, <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=\"http://forum.freeCodeCamp.com/t/how-to-get-help-when-you-are-stuck/19514\" target=\"_blank\">Read-Search-Ask</a> if you get stuck. Write your own code."
|
|
],
|
|
"challengeSeed": [
|
|
"function mutation(arr) {",
|
|
" return arr;",
|
|
"}",
|
|
"",
|
|
"mutation([\"hello\", \"hey\"]);"
|
|
],
|
|
"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.');",
|
|
"assert(mutation([\"voodoo\", \"no\"]) === false, 'message: <code>mutation([\"voodoo\", \"no\"])</code> should return false.');"
|
|
],
|
|
"type": "bonfire",
|
|
"isRequired": true,
|
|
"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"
|
|
],
|
|
"MDNlinks": [
|
|
"String.prototype.indexOf()"
|
|
],
|
|
"challengeType": 5,
|
|
"translations": {
|
|
"es": {
|
|
"title": "Mutaciones",
|
|
"description": [
|
|
"Crea una función que devuelva <code>true</code> si la cadena de texto del primer elemento de un arreglo contiene todas las letras de la cadena de texto del segundo elemento del arreglo.",
|
|
"Por ejemplo, <code>[\"hello\", \"Hello\"]</code>, debe devolver <code>true</code> 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 <code>true</code> porque todas las letras en \"line\" están presentes en \"Alien\".",
|
|
"Recuerda utilizar <a href='http://forum.freeCodeCamp.com/t/how-to-get-help-when-you-are-stuck/19514' target='_blank'>Leer-Buscar-Preguntar</a> si te sientes atascado. Intenta programar en pareja. Escribe tu propio código."
|
|
]
|
|
},
|
|
"pt-br": {
|
|
"title": "Mutações",
|
|
"description": [
|
|
"Retorne verdadeiro se o texto no primeiro elemento da matriz contém todas as letras do texto no segundo elemento da matriz.",
|
|
"Por exemplo, <code>[\"hello\", \"Hello\"]</code>, deve retornar verdadeiro pois todas as letras no segundo text estão presentes no primeiro texto.",
|
|
"Os argumentos <code>[\"hello\", \"hey\"]</code> devem retornar falso por o texto \"hello\" não contém a letra \"y\".",
|
|
"Por último, <code>[\"Alien\", \"line\"]</code>, deve retornar verdadeiro pois todas as letras em \"line\" estão presentes em \"Alien\".",
|
|
"Lembre-se de usar <a href=\"http://forum.freeCodeCamp.com/t/how-to-get-help-when-you-are-stuck/19514\" target=\"_blank\">Ler-Pesquisar-Perguntar</a> se você ficar travado. Escreva seu próprio código."
|
|
]
|
|
}
|
|
}
|
|
},
|
|
{
|
|
"id": "a9bd25c716030ec90084d8a1",
|
|
"title": "Chunky Monkey",
|
|
"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 two-dimensional array.",
|
|
"Remember to use <a href=\"http://forum.freeCodeCamp.com/t/how-to-get-help-when-you-are-stuck/19514\" target=\"_blank\">Read-Search-Ask</a> if you get stuck. Write your own code."
|
|
],
|
|
"challengeSeed": [
|
|
"function chunkArrayInGroups(arr, size) {",
|
|
" // Break it up.",
|
|
" return arr;",
|
|
"}",
|
|
"",
|
|
"chunkArrayInGroups([\"a\", \"b\", \"c\", \"d\"], 2);"
|
|
],
|
|
"tests": [
|
|
"assert.deepEqual(chunkArrayInGroups([\"a\", \"b\", \"c\", \"d\"], 2), [[\"a\", \"b\"], [\"c\", \"d\"]], 'message: <code>chunkArrayInGroups([\"a\", \"b\", \"c\", \"d\"], 2)</code> should return <code>[[\"a\", \"b\"], [\"c\", \"d\"]]</code>.');",
|
|
"assert.deepEqual(chunkArrayInGroups([0, 1, 2, 3, 4, 5], 3), [[0, 1, 2], [3, 4, 5]], 'message: <code>chunkArrayInGroups([0, 1, 2, 3, 4, 5], 3)</code> should return <code>[[0, 1, 2], [3, 4, 5]]</code>.');",
|
|
"assert.deepEqual(chunkArrayInGroups([0, 1, 2, 3, 4, 5], 2), [[0, 1], [2, 3], [4, 5]], 'message: <code>chunkArrayInGroups([0, 1, 2, 3, 4, 5], 2)</code> should return <code>[[0, 1], [2, 3], [4, 5]]</code>.');",
|
|
"assert.deepEqual(chunkArrayInGroups([0, 1, 2, 3, 4, 5], 4), [[0, 1, 2, 3], [4, 5]], 'message: <code>chunkArrayInGroups([0, 1, 2, 3, 4, 5], 4)</code> should return <code>[[0, 1, 2, 3], [4, 5]]</code>.');",
|
|
"assert.deepEqual(chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6], 3), [[0, 1, 2], [3, 4, 5], [6]], 'message: <code>chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6], 3)</code> should return <code>[[0, 1, 2], [3, 4, 5], [6]]</code>.');",
|
|
"assert.deepEqual(chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6, 7, 8], 4), [[0, 1, 2, 3], [4, 5, 6, 7], [8]], 'message: <code>chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6, 7, 8], 4)</code> should return <code>[[0, 1, 2, 3], [4, 5, 6, 7], [8]]</code>.');",
|
|
"assert.deepEqual(chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6, 7, 8], 2), [[0, 1], [2, 3], [4, 5], [6, 7], [8]], 'message: <code>chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6, 7, 8], 2)</code> should return <code>[[0, 1], [2, 3], [4, 5], [6, 7], [8]]</code>.');"
|
|
],
|
|
"type": "bonfire",
|
|
"isRequired": true,
|
|
"solutions": [
|
|
"function chunkArrayInGroups(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\nchunkArrayInGroups(['a', 'b', 'c', 'd'], 2);\n"
|
|
],
|
|
"MDNlinks": [
|
|
"Array.prototype.push()",
|
|
"Array.prototype.slice()"
|
|
],
|
|
"challengeType": 5,
|
|
"translations": {
|
|
"es": {
|
|
"title": "En mil Pedazos",
|
|
"description": [
|
|
"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 bidimensional.",
|
|
"Recuerda utilizar <a href='http://forum.freeCodeCamp.com/t/how-to-get-help-when-you-are-stuck/19514' target='_blank'>Leer-Buscar-Preguntar</a> si te sientes atascado. Intenta programar en pareja. Escribe tu propio código."
|
|
]
|
|
},
|
|
"pt-br": {
|
|
"title": "Em Pedaços",
|
|
"description": [
|
|
"Escreva uma funcção que divide uma matriz (primeiro argumento) em grupos de tamanho <code>size</code> (segundo argumento) e os retorna em uma matriz bidimensional.",
|
|
"Lembre-se de usar <a href=\"http://forum.freeCodeCamp.com/t/how-to-get-help-when-you-are-stuck/19514\" target=\"_blank\">Ler-Pesquisar-Perguntar</a> se você ficar travado. Escreva seu próprio código."
|
|
]
|
|
}
|
|
}
|
|
}
|
|
]
|
|
}
|