Created
February 1, 2018 02:11
-
-
Save guillefd/a2d3a5d9378a4dc1ae993e99eb1a729a to your computer and use it in GitHub Desktop.
Javascript Array: find item index and remove from Array
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function findAndRemove(array, item) { | |
const index = array.indexOf(item); | |
if(index>-1) { | |
array.splice(index, 1); | |
} | |
return array; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment