Skip to content

Instantly share code, notes, and snippets.

@Jagathishrex
Last active January 5, 2021 16:53
Show Gist options
  • Save Jagathishrex/3019e35693afd01417b14dd741645699 to your computer and use it in GitHub Desktop.
Save Jagathishrex/3019e35693afd01417b14dd741645699 to your computer and use it in GitHub Desktop.
function removeElement(arr, ele){
const index = arr.indexOf(2);
if (index > -1) {
arr.splice(index, 1);
}
}
const numbers = [1, 2, 3, 4];
removeElement(numbers, 2);
console.log(numbers);// [1, 3, 4];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment