The length
method gives the length of the string.
string.length
const randomString = 'This is a random string';
console.log(randomString.length); // Prints: 23
The length
method returned the length of the randomString
, it also counts white spaces.