|
Last change
on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago |
|
Added visualizations
|
-
Property mode
set to
100644
|
|
File size:
500 bytes
|
| Line | |
|---|
| 1 | function zip(...arrs) {
|
|---|
| 2 | let rowCount = 0;
|
|---|
| 3 | for (let i = 0; i < arrs.length; i++) {
|
|---|
| 4 | if (arrs[i].length > rowCount) {
|
|---|
| 5 | rowCount = arrs[i].length;
|
|---|
| 6 | }
|
|---|
| 7 | }
|
|---|
| 8 | const columnCount = arrs.length;
|
|---|
| 9 | const result = Array(rowCount);
|
|---|
| 10 | for (let i = 0; i < rowCount; ++i) {
|
|---|
| 11 | const row = Array(columnCount);
|
|---|
| 12 | for (let j = 0; j < columnCount; ++j) {
|
|---|
| 13 | row[j] = arrs[j][i];
|
|---|
| 14 | }
|
|---|
| 15 | result[i] = row;
|
|---|
| 16 | }
|
|---|
| 17 | return result;
|
|---|
| 18 | }
|
|---|
| 19 |
|
|---|
| 20 | export { zip };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.