Skip to content

Instantly share code, notes, and snippets.

@thedom85
Created June 6, 2022 13:52
Show Gist options
  • Save thedom85/47c412640a4e39ff71b01e600d93cea9 to your computer and use it in GitHub Desktop.
Save thedom85/47c412640a4e39ff71b01e600d93cea9 to your computer and use it in GitHub Desktop.
// https://www.codewars.com/kata/52597aa56021e91c93000cb0/train/javascript
function moveZeros(array) {
return array.filter(function(value){
return JSON.stringify(value) != "0" ; // filter no zero
}).concat(array.filter(function(value){
return JSON.stringify(value) == "0"; // filter zero
}));
}
console.log(JSON.stringify(moveZeros([1,2,0,1,0,1,0,3,0,1])) == JSON.stringify([1, 2, 1, 1, 3, 1, 0, 0, 0, 0]));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment