I am stuck in 14


#1

var myNames = prompt("Sunitha");
if ("myNames".length > 7 ) {

else {
console.log("You have a long name." );

}
}


#2

We do not put quotes around a variable name, else it becomes a string primitive.

myName.length

#3

You aren't doing anything in the if section and further you aren't closing the if section brackets.

You jump straight to else which is the condition called if "myNames".length is NOT greater than 7 (a.k.a. <= 7)


#4

Its like this @stirumal16.

var myNames = "Sunitha";
if ("myNames".length > 7 ) {
// Do This
}
else{
// Do that
}


#5

So four of us just about replied at the exact same time... interesting


#6

if( "myName".length >= 7 ) {
    console.log("You have a long name!");
}

is the example given in the lesson text. In this instance, "myName" is intentionally a string primitive, and JavaScript wraps it in a String object which has a length property.

When we have a variable that references a string object, the object has a length property that we query like so,

var myName = "Wee Gillis";
console.log(myName.length);  // 10