Character Counting

You are a writer creating character profiles for a novel. You need to count the total number of characters in the description of each character to ensure consistency and clarity.

Write a function named countCharacters that takes one parameter description representing the description of a character.

Follow Up: Try doing without any built-in functions.

Example 1

Input: countCharacters("Brave and courageous knight");
Output: 27

Example 2

Input: countCharacters("Clever detective with a sharp mind");
Output: 36

Example 3

Input: countCharacters("Mysterious traveler from distant lands");
Output: 40

Are you stuck on this problem?

Get detailed, step-by-step solution and improve your JavaScript skills.

  • Detailed Explanation: Each solution comes with a comprehensive explanation, helping you understand the logic and concepts thoroughly.
  • Learn to Write Better Code: Even if you have written the code, discover ways to improve it and adopt best practices.
  • Save Time: Don’t waste hours struggling—get the solution and learn efficiently.
  • Lifetime Access: Get access to lifetime solutions for all problems available
Get the Solution

" I struggled with this problem for hours, but the solution provided here was clear and easy to follow. It helped me understand where I went wrong and improved my coding skills significantly." - Jane D.

If you're not satisfied, I offer a 7-day money-back guarantee.