Write groupByLength(words) that returns an object mapping each word length (as a number key) to an array of the words with that length, preserving input order.
Signature: groupByLength(words) => Record<number, string[]>
Example: groupByLength(["a","bb","cc","ddd"]) → { 1: ["a"], 2: ["bb","cc"], 3: ["ddd"] }.
Reduce into an object; the key is word.length.
Create the array on first sight of a length, then push.
Test natijalarini ko'rish uchun kodingizni ishga tushiring.