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

    const truthy = [], falsy = [];
    for (const i of values) {
      (i ? truthy : falsy).push(i);
    }
If for some reason you did want to use reduce (and I see no reason to), it would be

    const [truthy, falsey] = exampleValues.reduce((arrays, i) => {
      arrays[+!i].push(i);
      return arrays;
    }, [[], []]);




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

Search: