Mr. Wiryo walks train #1 and each key decides the siding a wagon is coupled onto: what becomes of number keys in Object.groupBy and in Map.groupBy, and what…
The key idea
groupBy = the grouping reduce, standardised
Try it in this playground
Run the odd/even split Watch every wagon get asked its key and coupled onto its siding.
Change the key function The key function may work out anything: weight, tens, first letter.
Number keys: Object, then Map With Math.floor(n / 10), compare the key types on the board: string in Object, number in Map.
Try hasOwnProperty, then Object.hasOwn The first throws a TypeError on an object with no prototype; the second answers.