Make an object from a string
function mapString(string) {
  let map = {};
  for (let i = 0; i < string.length; i++) {
    let letter = string[i];
    if (map[letter]) {
      map[letter].push(i);
    } else {
      map[letter] = [i];
    }
  }
  return map;
}
console.log(mapString('blblllaaha'))
by Valeri Tandilashvili
2 years ago
JavaScript
objects
0
Pro tip: use ```triple backticks around text``` to write in code fences