programming-examples/js/Array/Write a JavaScript function to remove a specific element from an array..js

10 lines
228 B
JavaScript
Raw Normal View History

2019-11-15 12:59:38 +01:00
function remove_array_element(array, n)
{
var index = array.indexOf(n);
if (index > -1) {
array.splice(index, 1);
}
return array;
}
console.log(remove_array_element([2, 5, 9, 6], 5));