2 ms·
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
by MarkMc 7y ago
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));