You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// letterPositions.js should take in a sentence (as a string) and then return all the indices (zero-based positions) in the string where each character is found.
const letterPositions = function (sentence) {
const results = {};
for (let i = 0; i < sentence.length; i++) {
let letter = sentence[i];
if (sentence[i] === " ") {
// do nothing
} else if (results[letter]) {
results[letter].push(i);
// set results at this letter to the array of indexes