JSFiddle - React, Tailwind, and code Playground

by Nic Fontaine

JavaScript

var removeElement = function(nums, val) {
    var k = 0;
    for (let i = 0; i<nums.length; i++) {
		console.log(k);
        if (nums[k] === val) {
            nums.splice(nums[k], 1);
						nums.push("");
						console.log(nums);
        } else {
            k++;
        }
    }
    return nums;
};

console.log(removeElement([3, 2, 2, 3], 2));