Skip to main content
Changed map to forEach
Source Link
Qtax
  • 396
  • 2
  • 7

Anything wrong with the naive ways?

let large = [];
let small = [];

array.mapforEach((x) => (x > 10 ? large : small).push(x));

// or
for(const x of array){
    (x > 10 ? large : small).push(x);
}

Anything wrong with the naive ways?

let large = [];
let small = [];

array.map((x) => (x > 10 ? large : small).push(x));

// or
for(const x of array){
    (x > 10 ? large : small).push(x);
}

Anything wrong with the naive ways?

let large = [];
let small = [];

array.forEach((x) => (x > 10 ? large : small).push(x));

// or
for(const x of array){
    (x > 10 ? large : small).push(x);
}
Source Link
Qtax
  • 396
  • 2
  • 7

Anything wrong with the naive ways?

let large = [];
let small = [];

array.map((x) => (x > 10 ? large : small).push(x));

// or
for(const x of array){
    (x > 10 ? large : small).push(x);
}