characterMapping js

JavaScript
function characterMapping(str) {
  let charMap = {}
  let max = 0; 
  let maxChar = '';
  for (let char of str) {
    if (!charMap[char]) {      
      charMap[char] = 1;
    } else {
      charMap[char]++
    }
  }
  console.log(charMap);
}
function mostCommonChar(str) {  let charMap = {}  let max = 0         let maxChar = ''  for (let char of str) {    charMap[char] = charMap[char] + 1 || 1  }  for (let char in charMap) {   // look at each char in charMap    if (charMap[char] > max) {  // if the value is greater than max      max = charMap[char]       // update new max value      maxChar = char            // set the max character    }  }  return maxChar}
Source

Also in JavaScript: