UNPKG

@nknahom/lotide

Version:

Lotide is mini clone of the Lodash (https://lodash.com) library for learning JavaScript. What is Lodash? Lodash is a library that makes JavaScript easier by taking the hassle out of working with arrays, numbers, objects, strings, etc.

15 lines (13 loc) 373 B
const letterPositions = function (sentence) { const results = {}; // logic to update results here sentence.split("").forEach((letter, index) => { if (results[letter]) { results[letter].push(sentence.indexOf(letter, index)); } else { results[letter] = [sentence.indexOf(letter)]; } }); return results; }; module.exports = letterPositions;