1
I’m doing a Javascript programming course and I can’t solve a question.
Follows the Statement.
Declare a function called "move", which takes two arrays, removes the last element of the first and adds it to the second.
Example:
var umArray = [1, 2, 3];
var outroArray = [4, 5];
mover(umArray, outroArray);
umArray //deveria ser [1, 2]
outroArray //deveria ser [4, 5, 3]
My Answer
function mover (umArray,outroArray){
var umArray = [1, 2,3];
var outroArray = [4,5];
umArray.pop()
outroArray.push(2)
}
Mistakes:
The move function([1,2],[3,4]) must modify the first matrix so that its value is [1] and modify the second one so that its value is [3,4,2]
Thank you Luiz. (:
– Fabio Oliveira