Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function returnObject(aString){
- //object initializer
- var obj = {};
- //loop through letters of string and populate keys
- for (i = 0; i < aString.length; i++) {
- obj[aString[i]] = (obj[aString[i]] || 0) + 1;
- }
- //return obj to function
- return obj;
- }
- console.log(returnObject("helloooo"));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement