Skip to content

Commit e5e0393

Browse files
author
programmiri
committed
Add refactor
1 parent f468192 commit e5e0393

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

word-count/word-count.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ export class Words {
33
const words = string.toLowerCase().trim().split(/[\s]+/g)
44

55
return words.reduce((acc, curr) => {
6-
if (acc[curr] && typeof acc[curr] === 'number' ) {
6+
if (acc[curr] && !isNaN(acc[curr])) {
77
acc[curr] = acc[curr] + 1
88
} else {
99
acc[curr] = 1

0 commit comments

Comments
 (0)