Here is how you can get the length of a string in JavaScript.
- Use the length property
- The length property is read only
- Spaces within the string are counted as well
Here is an example below:
let str = "this is a string";
console.log(str.length); // 16