Hello and here is my problem.I have a task,i need to remove elements from an array and push them into another array and then return the array with removed elements. For example, in this case i have to remove all 0 values, and push them into 'a' array and then return 'a' array with there 0 values. I removed 0 values from the array by using splice method and loop, but i don't realy know how to push removed elemts into 'a' array, i've tried to use push method but i does not work for me. Hope you'll help me.Thank you everyone.
function moveZeros(array) {
var a = [];
for (var i = array.length - 1; i--;) {
if (array[i] == "0") {
array.splice(i, 1);
}
}
return a;
}
moveZeros([1, 2, 0, 1, 0, 1, 0, 3, 0, 1]);
arrayhas no zeros?i don't realy know how to push removed elemts into 'a' array.