Skip to content

Instantly share code, notes, and snippets.

@hussainb
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hussainb/9166944 to your computer and use it in GitHub Desktop.
Save hussainb/9166944 to your computer and use it in GitHub Desktop.
Remove Item From Array
function removeItem (array,toRemove){
var newArray = [];
for(var i=0;i<array.length;i++){
if(array[i]!=toRemove){
newArray.push(array[i]);
}
}
return newArray;
}
/*
Example
var inArr = [1,2,3,4,5];
var removeMe = 4;
var returnArr = removeItem (inArr,removeMe)
console.log(returnArr);
logs [1,2,3,5]
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment