Workshop › Text detective › Step 8 of 13
mat. and mat should be the same word. We remove punctuation from each word before counting it.
```js
const key = word.toLowerCase().replace(/[.,!?;:]/g, '')
```replace(pattern, '') replaces what matches the pattern with nothing, deleting it.[.,!?;:] matches any one of those characters; g means every match, not just the first.Add .replace(/[.,!?;:]/g, '') to the key line.
Skills: Types and values
← Count each word The most common word →