Javascript count characters in string

Javascript Mohit Mozumder

Problem:

Sometimes we need to count how many characters are here in a string. Like "home" here are 4 characters.


Solution:

to count characters in a string-
let text = "Home";
let length = text.length;
Output will 4.

Note: this code will count space as a character too. If you give "hi alex" then it will

give answer 7.


Thank you for reading the article. If you still face any problems feel free to contact us.