Skip to content

Commit a1323ec

Browse files
authored
Show only 'word' for 1 word found (#13)
1 parent 1bdf03e commit a1323ec

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/Main.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ const Main = () => {
7676
clearResults()
7777
}
7878

79+
function countFoundWords(fw) {
80+
return Object.entries(fw).reduce((acc, [wordLen, words]) => acc + words.length, 0)
81+
}
82+
7983
function handlePaths(paths) {
8084
const results = paths
8185
.map(path => ({
@@ -308,7 +312,7 @@ const Main = () => {
308312
processing ? 'Finding words...'
309313
: _.isEmpty(foundWords)
310314
? 'Fill in grid to begin'
311-
: `${Object.entries(foundWords).reduce((acc, [wordLen, words]) => acc + words.length, 0)} Words Found`
315+
: `${countFoundWords(foundWords)} Word${countFoundWords(foundWords) > 1 ? 's' : ''} Found`
312316
}
313317
</Typography>
314318
}

0 commit comments

Comments
 (0)