Workshop › Text detective › Step 9 of 13
The detective's finding: the word used most. We turn the map into a list, sort it by count and take the first.
```js
const top = [...counts].sort((a, b) => b[1] - a[1])[0]
(top ? '\nMost common: ' + top[0] + ' (' + top[1] + ')' : '')
```[...counts] is a list of [word, count] pairs.sort((a, b) => b[1] - a[1]) sorts by count, biggest first. [0] takes the first pair.top is undefined and nothing is added.top line.Most common part to the end of the report, as shown.Skills: Arrays and objects, Functions
← Drop the punctuation Shift a letter →