Javascript Property

Hi Everyone!

I just started to learn Javascript and I am now on the chapter of Introduction of Javascript “Properties .length”. I did the assignment as I learned and it’s correct, but I get confused why the number of characters and the result are not similar, but somehow, I got the assignment correct.

Here is the link: Learn JavaScript | Codecademy

my assignment is as followed:

The number of characters are 25, but the result is 30 and it’s correct. Shouldn’t the output be 25 as the number of characters are 25?

Thank you in advance :slight_smile:

Whitespace is also a character. There are 6 words in the string with each word separated by a space. Consequently, there are 5 spaces.

console.log("".length);
// 0

console.log(" ".length);
// 1
2 Likes