UNPKG

@mattseligman/lotide

Version:

Lotide is a mini clone of the Lodash Library to practice crating a personal npm package. It's like lodash, but without all that extra stuff. Just the things you need to start your project.

18 lines (14 loc) 383 B
const countLetters = function(word) { let letterCount = {}; let wordNoSpaces = word.split(" ").join(""); for (let letter of wordNoSpaces) { let alreadyCounted = Object.keys(letterCount).includes(letter); if (!alreadyCounted) { letterCount[letter] = 1; } else { letterCount[letter]++; } } return letterCount; }; module.exports = countLetters;