Forked from anonymous/bonfire-seek-and-destroy?solution=function%20destroyer(arr)%20%7B%0A%20%20%20args%20%3D%20Array.prototype.slice.call(arguments)%3B%0A%20%20%20args.slice(1).forEach(function(e%2Cl%2Ca)%20%7B%0A%20%20%20arr%20%3D%20arr.filter(function(value)%20%7B%0A%2
Created
November 30, 2015 11:19
-
-
Save srkama/ae46ed94d7cfbf7f1381 to your computer and use it in GitHub Desktop.
http://www.freecodecamp.com/srkama 's solution for Bonfire: Seek and Destroy
This file contains hidden or 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
| // Bonfire: Seek and Destroy | |
| // Author: @srkama | |
| // Challenge: http://www.freecodecamp.com/challenges/bonfire-seek-and-destroy?solution=function%20destroyer(arr)%20%7B%0A%20%20%20args%20%3D%20Array.prototype.slice.call(arguments)%3B%0A%20%20%20args.slice(1).forEach(function(e%2Cl%2Ca)%20%7B%0A%20%20%20arr%20%3D%20arr.filter(function(value)%20%7B%0A%20%20%20%20%20%20%20console.log(value%3D%3De)%3B%0A%20%20%20%20%20%20%20return%20(value!%3De)%3B%0A%20%20%20%20%20%7D)%3B%0A%20%20%20%7D)%3B%0A%20%20return%20arr%3B%0A%7D%0A%0Adestroyer(%5B%5B1%2C%202%2C%203%2C%201%2C%202%2C%203%5D%2C%202%2C%203%5D)%3B%0A | |
| // Learn to Code at Free Code Camp (www.freecodecamp.com) | |
| function destroyer(arr) { | |
| args = Array.prototype.slice.call(arguments); | |
| args.slice(1).forEach(function(e,l,a) { | |
| arr = arr.filter(function(value) { | |
| console.log(value==e); | |
| return (value!=e); | |
| }); | |
| }); | |
| return arr; | |
| } | |
| 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