We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f468192 commit e5e0393Copy full SHA for e5e0393
word-count/word-count.js
@@ -3,7 +3,7 @@ export class Words {
3
const words = string.toLowerCase().trim().split(/[\s]+/g)
4
5
return words.reduce((acc, curr) => {
6
- if (acc[curr] && typeof acc[curr] === 'number' ) {
+ if (acc[curr] && !isNaN(acc[curr])) {
7
acc[curr] = acc[curr] + 1
8
} else {
9
acc[curr] = 1
0 commit comments