String Length and Number Length
let number = 1010;
let name = "Ajay";
Finally, we are checking the value of both the variable for their length property.
Any idea, what should be the output of above code statement.
let number = 1010; let name = "Ajay"; console.log(name.length); // output => 🧐 ? console.log(number.length); // output => 🧐 ? // Made with ❤️, by @jsstartup
Now, you know the answer is 4, undefined. But why, doesn’t it should give 4, 4 because both have length 4. Let me explain.
At last, That’s why we get an answer “4, undefined”
Let me know in the comment section, what you think about it.
I hope you understand the concept and logic behind it.
But wait, i have something more for you –
- JS Quiz – for loop iterate array in two ways
- JS Quiz – array element duplicate count with for loop
And last but not the least, don’t forget to like, comment and share. It gives us a morale boost to remain to continue. Also, join our Facebook Page
If you have any questions, please feel free to ask me in the comment section and also let me know if you have any suggestions. As suggestions are always welcome.