Skip to content

Instantly share code, notes, and snippets.

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 robertsheacole/abd26793fcc68d8cf74e to your computer and use it in GitHub Desktop.
Save robertsheacole/abd26793fcc68d8cf74e to your computer and use it in GitHub Desktop.
http://www.freecodecamp.com/robertsheacole 's solution for Bonfire: Seek and Destroy
// Bonfire: Seek and Destroy
// Author: @robertsheacole
// Challenge: http://www.freecodecamp.com/challenges/bonfire-seek-and-destroy#
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function destroyer(arr) {
var args = arr.slice.call(arguments);
args.splice(0, 1);
var newArray = [];
for(var i = 0; i < arr.length; i++){
for(var j = 0; j < arr.length; j++){
if (args[j] === arr[i]){
delete arr[i];
}
}
}
newArray = arr.filter(function(arr){
return Boolean(arr);
});
return newArray;
}
destroyer([1, 2, 3, 1, 2, 3], 2, 3);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment