I want to count the number of occurrences of each character in a given string using JavaScript.
For example:
var str = \"I want to count the number
let str = "atul kumar srivastava"; let obj ={}; for(let s of str)if(!obj[s])obj[s] = 1;else obj[s] = obj[s] + 1; console.log(obj)