What’s up programmer, are you okay? Let’s learn something new!
We can use the string length for some check using the “if” statement and determine the course of our software depending on the received value
Or even some other problem that we need to solve on this data
For this case we use the <length>
With this property we will receive a number value, with the number of characters in the string, learn how to use it:
let nome = "Matheus"; console.log(nome.length); // 7
Also, another important use of length is to check the number of elements in an array.
The same way we use length in a string, we can use this property on the array
The return will be a number too, but with the number of elements of the array in question, check it out:
In this article we learned about the possibility of returning the number of characters in a string applying the length property
Furthermore, the same property can check the number of elements that an array contains.