-
-
Save marksabado-pulsar/ea608161df2567a44bd90e6b9fb9ae33 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var a = [1,2,0,1,0,0,3,6]; | |
function moveZeroes(array) { | |
var zeroes = a.filter(item => item === 0); | |
var noZero = a.filter(item => item !== 0); | |
zeroes.forEach(zero => { | |
noZero.push(zero) | |
}) | |
return noZero; | |
} | |
console.log(moveZeroes(a)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment