Created
December 1, 2023 19:21
-
-
Save ChathuraGH/5125b4a041e2f1b1601d3a2152491db9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
//source | |
// https://stackoverflow.com/questions/19480916/count-number-of-occurrences-for-each-char-in-a-string | |
// https://stackoverflow.com/a/60648545/13861187 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment