I was trying to shift array element which contain 0 elements at the very end whenever it was found in the array. So, I have the below array, just wanted to know how we can shift all 0 elements at the end without sorting the element. Non-zero element order should not get affected. I was able to place 0 elements at the end using the sorting method but was unable to other solutions to achieve the expected output below.
Can anyone look into that sample how we get the expected output?
Sample Array
const arr = [4,5,1,0,3,8,0,9,2,0,4]
Expected output
const arr = [4,5,1,3,8,9,2,4,0,0,0]