Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements.
(요약) 0
을 제일 뒤로 다 몰아넣어라.
var moveZeroes = function(nums) { const length = nums.length; for(let i = length - 1; i >= 0; i--){ if(!nums[i]){ nums.push(nums.splice(i, 1)[0]); } } return nums };
배열 마지막 요소부터 순회하면서
0
이면 잘라서 배열 마지막으로 보냄.