Skip to content

Commit f755a3e

Browse files
committed
Added and completed difference for Underbar.
1 parent ce7a946 commit f755a3e

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/underbar.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -690,6 +690,20 @@ var _ = {};
690690
// Take the difference between one array and a number of other arrays.
691691
// Only the elements present in just the first array will remain.
692692
_.difference = function(array) {
693+
var args=Array.prototype.slice.call(arguments, 1);
694+
var testArray=array.slice();
695+
var tempArray=[];
696+
697+
_.each(args, function(arr) {
698+
tempArray=[];
699+
_.each(testArray, function(val, key) {
700+
arr.indexOf(val)===-1 ? tempArray.push(val) : null;
701+
});
702+
testArray=tempArray.slice();
703+
});
704+
705+
return testArray;
706+
693707
};
694708

695709

0 commit comments

Comments
 (0)