Reduce, Reduce, Reduce!

const word = 'onomatopoeia'
function letterTally(word){}
function letterTally(word){
const split = word.toLowerCase().split('')
}
function letterTally(word){
const split = word.toLowerCase().split('')
return split.reduce( (acc, curr) => {

}, {})
}
function letterTally(word){
const split = word.toLowerCase().split('');
return split.reduce( (acc, curr) => {
if (acc[curr]) {
acc[curr]++;
return acc;
} else {
acc[curr] = 1;
return acc;
}
}, {})
}
const word = 'onomatopoeia'console.log(letterTally(word))
// prints: { o: 4, n: 1, m: 1, a: 2, t: 1, p: 1, e: 1, i: 1 }

--

--

--

Full-stack web developer with a background in the service industry, sound design, audio engineering, and theatre performance.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Leetcode Two Sum Javascript

How to Observe Changes to the DOM without using a JavaScript framework

Commerce.js Versus Nacelle Versus Saleor

5 Free JavaScript Chart Libraries to Make Your Data Pop

Get ready frens for our 5th episode of Web3 1:1 Talk show on Building web3 video meetings platform…

Build and deploy React on Serverless backend Platform [Part 1]

10 Tips for Javascript Debugging Like a PRO with Console

Debug Your AWS CDK Application in VS Code

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Kamrin Kennedy

Kamrin Kennedy

Full-stack web developer with a background in the service industry, sound design, audio engineering, and theatre performance.

More from Medium

CS373 Spring 2022: Isaac Adams

CS373 Spring 2022: Dinesh Krishnan Balakrishnan

‘git’ is not recognized as an internal or external command | Git Error Solve

CS373 Spring 2022: Presley Heikkila