JSFiddle - React, Tailwind, and code Playground

by Amir Danish

JavaScript

var obj={}
var repeats=[];
str='welcom to mone lion'

for(x = 0, length = str.length; x < length; x++) {
    var l = str.charAt(x)
    obj[l] = (isNaN(obj[l]) ? 1 : obj[l] + 1);
}

console.log(obj)