JSFiddle - React, Tailwind, and code Playground

by Yurii Predborskyi

JavaScript

/**
 * @param {number[]} nums
 * @return {void} Do not return anything, modify nums in-place instead.
 */
var moveZeroes = function(nums) {
	let len = nums.length;
  for(let i = len; i >= 0; i--) {
    if (nums[i] === 0) {
      nums.splice(i, 1);
      nums.push(0);
    }
  }
};

let arr = [0,0,1];
moveZeroes(arr);
console.log(arr);