DEV Community

Discussion on: Javascript Array Condensing

Collapse
vskpro profile image
Sai Kiran Veeraneni • Edited on

function shifter(arr) {
const zero = [];
const numbers = [];
arr.forEach(item => {
if(item === 0){
zero.push(item);
} else {
numbers.push(item);
}
});
return ([...numbers,...zero]);
}