Created
December 6, 2015 23:55
-
-
Save anonymous/9231a94abfd505d5fdff to your computer and use it in GitHub Desktop.
Revisions
-
There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,27 @@ // Bonfire: Sorted Union // Author: @dannycoder // Challenge: http://www.freecodecamp.com/challenges/bonfire-sorted-union# // Learn to Code at Free Code Camp (www.freecodecamp.com) function unite(arr1, arr2, arr3) { var newArray = []; for(var i = 0; i < arguments.length; i++) { for (var j = 0; j < arguments[i].length; j++) { //add first element to array if( i === 0 && j === 0) { newArray.push(arguments[i][j]); continue; } //add next element if not found in the @newArray if(newArray.indexOf(arguments[i][j]) === -1){ newArray.push(arguments[i][j]); console.log(arguments[i][j]); } } } return newArray; } unite([1, 3, 2], [5, 2, 1, 4], [2, 1]);