Skip to content

Latest commit

 

History

History
10 lines (9 loc) · 444 Bytes

create-object-from-string-showing-repetitions.md

File metadata and controls

10 lines (9 loc) · 444 Bytes

Part3

Write a function that creates an Object from the given string with the characters as keys and the repetitions for the key as values for the key.

function createObjectShowingRepetitions(str){
// write your code here
}
console.log(createObjectShowingRepetitions("hello")); // {'h' :1,'e' :1, 'l' : 2, 'o' :1}
console.log(createObjectShowingRepetitions("aeroplane"));// {'a' :2, 'e' :2, 'r' :1, 'o' :1, 'p' :1, 'l' :1,'n':1}