Skip to content

Commit

Permalink
Show only 'word' for 1 word found (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
jwblangley authored Aug 31, 2020
1 parent 1bdf03e commit a1323ec
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Main.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ const Main = () => {
clearResults()
}

function countFoundWords(fw) {
return Object.entries(fw).reduce((acc, [wordLen, words]) => acc + words.length, 0)
}

function handlePaths(paths) {
const results = paths
.map(path => ({
Expand Down Expand Up @@ -308,7 +312,7 @@ const Main = () => {
processing ? 'Finding words...'
: _.isEmpty(foundWords)
? 'Fill in grid to begin'
: `${Object.entries(foundWords).reduce((acc, [wordLen, words]) => acc + words.length, 0)} Words Found`
: `${countFoundWords(foundWords)} Word${countFoundWords(foundWords) > 1 ? 's' : ''} Found`
}
</Typography>
}
Expand Down

0 comments on commit a1323ec

Please sign in to comment.