0
What is length and how to use it?
3 Answers
+ 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.
+ 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");
};
+ 1
Hey there Unknown ,
Lenght can be used in many cases; it's used to find the lenght of an element (strings, array,....) :)