Skip to content

Instantly share code, notes, and snippets.

@trickpattyFH20
Last active June 23, 2017 08:38
Show Gist options
  • Save trickpattyFH20/52736493ab6036e6574670a47ed514f0 to your computer and use it in GitHub Desktop.
Save trickpattyFH20/52736493ab6036e6574670a47ed514f0 to your computer and use it in GitHub Desktop.
splice zeros
var a = [0, 0, 1, 0, 2, 3, 0, 4, 0, 5];
var idx;
function findIdx() {
idx = a.indexOf(0);
return idx;
}
while (findIdx() !== -1) {
a.splice(idx, 1);
}
console.log(a);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment