Length of a String
Remember that a string is a sequence of characters. The length of a string is the number of characters in it. Every string in JS has a length property which stores the number of characters in the string. For example, "keep it up".length will evaluate to 10 (remember, spaces are characters too). Get the length of the string stored in the variable ls.
ls.length => 11
Now you have a way to get the length of long sentences, instead of counting the characters one by one!
No comments:
Post a Comment