Skip to content

Commit d6f7058

Browse files
committed
Finished zip for Underbar.
1 parent e8c1d27 commit d6f7058

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/underbar.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -633,13 +633,17 @@ var _ = {};
633633
_.zip = function() {
634634
var results=[];
635635
var args=Array.prototype.slice.call(arguments);
636+
var max=0;
636637
_.each(args, function(arr) {
637-
_.each(arr, function(val, index) {
638-
if (results[index]===undefined) {
638+
arr.length > max ? max=arr.length : null;
639+
});
640+
_.each(args, function(arr) {
641+
for (var i=0; i<max; i++) {
642+
if (results[i]===undefined) {
639643
results.push([]);
640644
}
641-
results[index].push(val);
642-
});
645+
results[i].push(arr[i]);
646+
}
643647
});
644648

645649
return results;

0 commit comments

Comments
 (0)