Typescript Split Partition Array By Condition

[Solved] Typescript Split Partition Array By Condition | Perl - Code Explorer | yomemimo.com
Question : typescript split/partition array by condition

Answered by : abhishek-ki9yinatp2t5

const [small, large] = // Use "deconstruction" style assignment [12, 5, 8, 130, 44] .reduce((result, element) => { result[element <= 10 ? 0 : 1].push(element); // Determine and push to small/large arr return result; }, [[], []]); // Default small/large arrays are empty

Source : https://codereview.stackexchange.com/questions/162878/partitioning-an-array-based-on-a-condition-in-javascript | Last Update : Mon, 24 May 21

Answers related to typescript split partition array by condition

Code Explorer Popular Question For Perl