Search posts, tags, users, and pages
Ady Ngom
Building M.A.N.T.I.S (mantistech.io) | Angular Google Developer Expert | Talk and Teach about #Angular, #Javascript, #Web Development & Deve
There are usually two variations of this challenge, the only difference being if the zeroes need to be moved to the end (right) or start (left ) of the array. Below is the challenge as copied from the geeksforgeeks website: Given an array of rando...
Tony B
Nice article.
If performance isn't a huge concern, you can also just do this.
arr.sort((a,b) => !!b - !!a)
In recent versions of JavaScript the array sort is stable so the order of equal elements from the compare remains unchanged
Tony B
Nice article.
If performance isn't a huge concern, you can also just do this.
arr.sort((a,b) => !!b - !!a)In recent versions of JavaScript the array sort is stable so the order of equal elements from the compare remains unchanged