Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- arr = "Captain America".toLowerCase().split('');
- obj = {};
- for(v in arr) {
- obj[arr[v]] = obj[arr[v]] || 0;
- obj[arr[v]]++;
- }
- for(v in obj) {
- console.log('The letter ' + v + ' appeared ' + obj[v] + ' times.');
- }
Add Comment
Please, Sign In to add comment