DEV Community 👩‍💻👨‍💻

Discussion on: JavaScript Challenge 3: Remove Zeroes

Collapse
webit profile image
webit

How about:

const arr = [7, 2, 3, 0, 4, 6, 0, 0, 13, 0, 78, 0, 0, 19, 14];

const nextArr = [...arr.filter(Boolean), ...arr.filter((v) => !v)];
Enter fullscreen mode Exit fullscreen mode
Collapse
albertomontalesi profile image
AlbertoM Author

Nice one line solution!

Collapse
t0nyba11 profile image
Tony B

"You are NOT allowed to use any temporary arrays or objects. You are also not allowed to use any Array.prototype or Object.prototype methods."