Skip to content

Commit e8c1d27

Browse files
committed
Began zip for Underbar. Still need to pad with 'undefined' but otherwise working.
1 parent 27a4381 commit e8c1d27

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/underbar.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -631,6 +631,18 @@ var _ = {};
631631
// Example:
632632
// _.zip(['a','b','c','d'], [1,2,3]) returns [['a',1], ['b',2], ['c',3], ['d',undefined]]
633633
_.zip = function() {
634+
var results=[];
635+
var args=Array.prototype.slice.call(arguments);
636+
_.each(args, function(arr) {
637+
_.each(arr, function(val, index) {
638+
if (results[index]===undefined) {
639+
results.push([]);
640+
}
641+
results[index].push(val);
642+
});
643+
});
644+
645+
return results;
634646
};
635647

636648
// Takes a multidimensional array and converts it to a one-dimensional array.

0 commit comments

Comments
 (0)