---
title: "Discussion on \"Moving Zeros Code Challenge - JavaScript Data Structures and Algorithms\" | Hashnode"
description: "Discussion on \"Moving Zeros Code Challenge - JavaScript Data Structures and Algorithms\". 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:\nGiven an array of rando..."
url: "https://hashnode.com/posts/moving-zeros-code-challenge-javascript-data-structures-and-algorithms/5fbd4c20ec43af1ba609509c"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Moving Zeros Code Challenge - JavaScript Data Structures and Algorithms](https://adyngom.com/moving-zeros-code-challenge-javascript-data-structures-and-algorithms?utm_source=hashnode&utm_medium=feed)

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...

Nov 24, 2020 · 7 min read · adyngom.com  
Updated Jul 1, 2022  
Read the article

-   [#javascript](https://hashnode.com/tag/javascript)
-   [#100daysofcode](https://hashnode.com/tag/100daysofcode)
-   [#data-structures](https://hashnode.com/tag/data-structures)
-   [#algorithms](https://hashnode.com/tag/algorithms)
-   [#challenge](https://hashnode.com/tag/challenge)

## Written by

[Ady Ngom](https://hashnode.com/@adyngom)

@adyngom · Alpharetta, GA

  
[View profile](https://hashnode.com/@adyngom)

Building M.A.N.T.I.S (mantistech.io) | Angular Google Developer Expert | Talk and Teach about #Angular, #Javascript, #Web Development & Deve

Ady's first interaction with a computer was playing PacMan but he was more interested in knowing how it was built than how much fun it was to play it. For the past 20 years, Ady has strived in building simple, engaging and very intuitive consumer facing products. As a JavaScript Teach Lead and UI Architect, he spends a bulk of his time producing intuitive systems that are easy to scale and maintain. When away from the keyboard, he enjoys the Georgia outdoors with his wife and two daughters. To him, the unpredictable weather is a known issue that simply adds to the overall charm and he would not have it otherwise.

## Responses 1

Markdown supported · ⌘↵ to post

[Tony B](https://hashnode.com/@octree)

[Jan 6, 2021](https://hashnode.com/posts/moving-zeros-code-challenge-javascript-data-structures-and-algorithms/5fbd4c20ec43af1ba609509c/comment/5ff61acce8e57e1374e6af23)

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_
