Where i am stuck? i did not know what i did wrong in this code? Help me


#1


https://www.codecademy.com/en/courses/getting-started-v2/2/2?curriculum_id=506324b3a7dffd00020bf661#

TypeError message for undefine length.

. 
// Here is an example of using the greater than (>) operator.
console.log(15 > 4).length ; // 15 > 4 evaluates to true, so true is printed.

// Fill in with >, <, === so that the following print out true:
console.log("Xiao Hui").length > 122;
console.log("Goody Donaldson").length < 8;
console.log(8*2).length ==  16;


#2

this line:

console.log(15 > 4).length ;

you can't call length on numbers, length is for string and arrays, then this line:

console.log("Xiao Hui").length > 122;

console.log() logs so the console, it should log the name the name to the console when larger then 122 characters, but this should all be in console.log:

console.log("Xiao Hui".length > 122);

since you want the length of the string, and then compare it


#3

but at last code
console.log(8*2).length ;
how to make it in true and false form.
is it by making its comparation.


#4

but you don't need length, you can just check if 8 * 2 equals 16, basic math


#5

ok got it.
but what in this...
var userAnswer = prompt("Do you want to race Bieber on stage");
if(yes)
{
console.log("You and Bieber start racing. It's neck and neck! You win by a shoelace!");
}
else{
console.log("Oh no! Bieber shakes his head and sings 'I set a pace, so I can race without pacing.");
}
what is wrong in this?


#6

that is a different question all together, according to guidelines you would have to make a new topic, but the problem seems that you don't compare userAnswer (the variable which holds the result of the prompt) with yes, don't forget yes is a string


#7

but now also.
var userAnswer = prompt("Do you want to race Bieber on stage");
if(userAnswer=0)
{
console.log("You and Bieber start racing. It's neck and neck! You win by a shoelace!");
}
else{
console.log("Oh no! Bieber shakes his head and sings 'I set a pace, so I can race without pacing.");
}
i changed but the answer is the same for both yes or no from user.


#8

please, this topic was for a different question. IF you have more question, create a new topic please


#9

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.