slice
y splice
para copiar cada elemento de la primera matriz en la segunda matriz, en orden.
Comenzar a insertar elementos en el índice n
de la segunda matriz.
Devuelve la matriz resultante. Las matrices de entrada deben permanecer iguales después de que se ejecute la función.
Recuerda usar Read-Search-Ask si te atascas. Escribe tu propio código.
frankenSplice([1, 2, 3], [4, 5], 1)
debe devolver [4, 1, 2, 3, 5]
.'
testString: 'assert.deepEqual(frankenSplice([1, 2, 3], [4, 5], 1), [4, 1, 2, 3, 5], "frankenSplice([1, 2, 3], [4, 5], 1)
should return [4, 1, 2, 3, 5]
.");'
- text: ' frankenSplice([1, 2], ["a", "b"], 1)
debe devolver ["a", 1, 2, "b"]
.'
testString: 'assert.deepEqual(frankenSplice(testArr1, testArr2, 1), ["a", 1, 2, "b"], "frankenSplice([1, 2], ["a", "b"], 1)
should return ["a", 1, 2, "b"]
.");'
- text: ' frankenSplice(["claw", "tentacle"], ["head", "shoulders", "knees", "toes"], 2)
debe devolver ["head", "shoulders", "claw", "tentacle", "knees", "toes"]
. '
testString: 'assert.deepEqual(frankenSplice(["claw", "tentacle"], ["head", "shoulders", "knees", "toes"], 2), ["head", "shoulders", "claw", "tentacle", "knees", "toes"], "frankenSplice(["claw", "tentacle"], ["head", "shoulders", "knees", "toes"], 2)
should return ["head", "shoulders", "claw", "tentacle", "knees", "toes"]
.");'
- text: Todos los elementos de la primera matriz se deben agregar a la segunda matriz en su orden original.
testString: 'assert.deepEqual(frankenSplice([1, 2, 3, 4], [], 0), [1, 2, 3, 4], "All elements from the first array should be added to the second array in their original order.");'
- text: La primera matriz debe permanecer igual después de que se ejecute la función.
testString: 'assert(testArr1[0] === 1 && testArr1[1] === 2, "The first array should remain the same after the function runs.");'
- text: La segunda matriz debe permanecer igual después de que se ejecute la función.
testString: 'assert(testArr2[0] === "a" && testArr2[1] === "b", "The second array should remain the same after the function runs.");'
```