Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[challenge] Count chars #65

Copy link
Copy link
@403-html

Description

@403-html
Issue body actions

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

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.