0

What is length and how to use it?

2nd Mar 2021, 6:08 AM
Unknown
Unknown - avatar
3 ответов
+ 4
Well, that's a contextual question. Can you tell more about it, e.g. where you see it, cause 'length" can be variable name, method name or something else. Need clarity on the context there.
2nd Mar 2021, 6:21 AM
Ipang
+ 3
.length can be used to find the length of an array, it's similar to python "len()" for example, var fruits = ["apple", "guava", "strawberry"]; if (fruits.length >== 3) { console.log("we have enough fruits"); } else if (fruit.length > 7) { console.log("It's too much"); } else{ console.log("-_- wut the"); };
2nd Mar 2021, 6:31 AM
Dr. Tempoville
Dr. Tempoville - avatar
+ 1
Hey there Unknown , Lenght can be used in many cases; it's used to find the lenght of an element (strings, array,....) :)
2nd Mar 2021, 8:15 AM
Matthew
Matthew - avatar