JSFiddle - React, Tailwind, and code Playground

by mtambulut

JavaScript

// functiıon1
/*
const charOccurances = st => {
console.log([...st]);
alert("1");
[...st].reduce((acc,character) => ({ ...acc, [character] : (acc[character] || 0) + 1}),{});

}
*/
function charOccurances(st){
[...st].reduce((acc,character) => ({ ...acc, [character] : (acc[character] || 0) + 1}),{});

}



console.log(charOccurances("cabacccc"));