JSFiddle - React, Tailwind, and code Playground

by Ashish Kasama

JavaScript

const numberTobeRemoved = 2;
let numArray = [58, 38, 3, 2, 12, 56, 7, 2];
let rIndex = -1;
do {
  rIndex = numArray.indexOf(numberTobeRemoved);
  if (rIndex != -1)
    numArray.splice(rIndex, 1);
} while (rIndex != -1)
console.log(numArray);