-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Challenge: Write a function called countChars that takes a string as input and returns an object that contains the count of each character in the string.
For example, if the input string is "Hello, world!", the function should return an object like this:
{
H: 1,
e: 1,
l: 3,
o: 2,
",": 1,
" ": 1,
w: 1,
r: 1,
d: 1,
"!": 1
}
Instructions:
- Write a function called countChars that takes a string as input and returns an object.
- The object should contain the count of each character in the input string.
- The function should be case-sensitive, so "H" and "h" should be counted as different characters.
- If a character appears multiple times in the input string, the object should contain the correct count for that character.
- Test your function by calling it with different input strings and printing the output to the console.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request