3
I apologize in advance for the beginner’s doubt, but I’m stuck in the next problem. The exercise asks us to declare a function called "replace" that has two arrays (arrayA, arrayB) and then remove the last element of the first (arrayA) and add it to the second (arrayB).
Being:
var arrayA = [1, 2, 3];
var arrayB = [4, 5];
Now, using pop and push, my code is like this:
var arrayA = [1, 2, 3];
var arrayB = [4, 5];
arrayA.pop ();
arrayB.push (3);
The point is I need to put within of a function or with a function (I really don’t know how the exercise wants us to do it) and I have no idea how to fit it into a function. So far I’ve tried this, and it only makes a mistake:
var arrayA = [1, 2, 3];
var arrayB = [4, 5];
arrayA.pop ();
arrayB.push (3);
function substituir (){
var resultado = (arrayA,arrayB);
return resultado;
}
Any idea how to solve this problem?
Luigi you are a superhero! The question of the problem is really vague and left me extremely confused, but this solution worked 100 percent!! Thank you so much!!
– kathryn