Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
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);
}