Skip to content

Commit

Permalink
feat: add total counter
Browse files Browse the repository at this point in the history
  • Loading branch information
Shadman Kolahzary committed Nov 18, 2021
1 parent 729dcc5 commit 33a2c4a
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,16 @@ export function generate_response(characters: string, filter: keyof typeof filte
result += `\n${x.word}(${x.level})(${x.score})`
})

return `Given characters: \`${characters}\`\nFilter: ${filters[filter].title}\nResult: \`\`\`${result}\`\`\``;;
const sum = matchedWords.reduce((sum, current) => {
sum[current.level]+=1;
return sum
},{
a: 0,
i: 0,
b: 0
})

return `Given characters: \`${characters}\`\nFilter: ${filters[filter].title}\nResult: \`\`\`${result}\`\`\`\nTotal: ${matchedWords.length} (${sum.a}a,${sum.i}i,${sum.b}b)`
}

export function generate_keyboard(currentFilter: keyof typeof filters) {
Expand Down

0 comments on commit 33a2c4a

Please sign in to comment.