Hacker News new | past | comments | ask | show | jobs | submit login

That was my quick reaction as well... I think it would need something like the python example below, where you first check the lengths of the two arrays/lists, and then iterate over that, and not directly over the length of the first list.

    iter_limit = Math.min(ls1.length, ls2.length);
    for(let i = 0; i < iter_limit; i++)...



  function zip(arr_a, arr_b) {
    const len = arr_a.length < arr_b.length ? arr_a.length : arr_b.length;

    return arr_a.slice(0, len).map((el, idx) => [el, arr_b[idx]]);
  }




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: