length property with strings to find/count the number of characters in a string
When you use the
Let's create 2 variables:
let firstName = 'Ada'; let myData = firstName.length; // returns 3 console.log(myData);
The way it's used is after or at the end of a variable with a
.length like so
If you check the
typeof both variables the
firstName is a string.
myData is a number.
console.log(typeof firstName); // string console.log(typeof myData); // number
If you are a
visual person here's a
video tutorial with code editor and whiteboard example.
Thanks for reading this.