Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The 'One loop two arrays' example looks like premature optimisation to me. Going through the list twice is much easier to understand:

  let exampleValues = [2, 15, 8, 23, 1, 32];
  let truthFn = (x) => x > 10;
  let truthyValues = exampleValues.filter(truthFn);
  let falsyValues = exampleValues.filter((x) => !truthFn(x));


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

Search: