JSFiddle - React, Tailwind, and code Playground
JavaScript
var testArray = [1,2,3,4,5,6,7,8,9,10];
var removeItem = 5;
console.log(testArray);
//Method 1
var index = testArray.indexOf(removeItem);
if (index !== -1){
testArray.splice(index, 1);
}
console.log(testArray);
//Reset
testArray = [1,2,3,4,5,6,7,8,9,10];
//Method 2
testArray = testArray.filter(function(element){
return element !== removeItem;
});
console.log(testArray);