Created
June 6, 2022 13:52
-
-
Save thedom85/47c412640a4e39ff71b01e600d93cea9 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// 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