Swap Slasher Flick with more difficult challenge

This commit is contained in:
BKinahan
2016-08-12 15:30:21 +00:00
parent 8addca59de
commit 3d6e2e9a5c

View File

@ -529,49 +529,45 @@
} }
}, },
{ {
"id": "ab31c21b530c0dafa9e241ee", "id": "579e2a2c335b9d72dd32e05c",
"title": "Slasher Flick", "title": "Slice and Splice",
"description": [ "description": [
"Return the remaining elements of an array after chopping off <code>n</code> elements from the head.", "You are given two arrays and an index.",
"The head means the beginning of the array, or the zeroth 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.",
"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." "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=\"//github.com/FreeCodeCamp/freecodecamp/wiki/FreeCodeCamp-Get-Help\" target=\"_blank\">Read-Search-Ask</a> if you get stuck. Write your own code."
], ],
"challengeSeed": [ "challengeSeed": [
"function slasher(arr, howMany) {", "function frankenSplice(arr1, arr2, n) {",
" // it doesn't always pay to be first", " // It's alive. It's alive!",
" return arr;", " return arr2;",
"}", "}",
"", "",
"slasher([1, 2, 3], 2);" "frankenSplice([1, 2, 3], [4, 5, 6], 1);"
],
"tail": [
"var testArr1 = [1, 2];",
"var testArr2 = ['a', 'b'];"
], ],
"tests": [ "tests": [
"assert.deepEqual(slasher([1, 2, 3], 2), [3], 'message: <code>slasher([1, 2, 3], 2)</code> should return <code>[3]</code>.');", "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(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(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(slasher([1, 2, 3], 9), [], 'message: <code>slasher([1, 2, 3], 9)</code> should return <code>[]</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(slasher([1, 2, 3], 4), [], 'message: <code>slasher([1, 2, 3], 4)</code> should return <code>[]</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.deepEqual(slasher(['burgers', 'fries', 'shake'], 1), ['fries', 'shake'], 'message: <code>slasher([\"burgers\", \"fries\", \"shake\"], 1)</code> should return <code>[\"fries\", \"shake\"]</code>.');", "assert(testArr1[0] === 1 && testArr1[1] === 2, 'message: The first array should remain the same after the function runs.');",
"assert.deepEqual(slasher([1, 2, 'chicken', 3, 'potatoes', 'cheese', 4], 5), ['cheese', 4], 'message: <code>slasher([1, 2, \"chicken\", 3, \"potatoes\", \"cheese\", 4], 5)</code> should return <code>[\"cheese\", 4]</code>.');" "assert(testArr2[0] === 'a' && testArr2[1] === 'b', 'message: The second array should remain the same after the function runs.');"
], ],
"type": "bonfire", "type": "bonfire",
"isRequired": true, "isRequired": true,
"solutions": [ "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" "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": [ "MDNlinks": [
"Array.prototype.slice()", "Array.prototype.slice()",
"Array.prototype.splice()" "Array.prototype.splice()"
], ],
"challengeType": 5, "challengeType": 5
"translations": {
"es": {
"title": "Vuélale la cabeza",
"description": [
"Crea una función que devuelva los elementos restantes de un arreglo después de eliminar <code>n</code> elementos de la cabeza.",
"Por cabeza nos referimos al inicio de un arreglo, comenzando por el índice 0.",
"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."
]
}
}
}, },
{ {
"id": "af2170cad53daa0770fabdea", "id": "af2170cad53daa0770fabdea",