I just finished my first course, and I'm trying to find this bug


#1

I finished the last lesson with this code

  // Not sure where to begin? Check the Hint!
var myColor = "blue";
var myName = "Forrest";
if ( myName >= myColor) {
    console.log("I finished my first course!")
}
else {
    console.log("I didn't finsih it yet.")
}

Why did it continue to spit out my else statement if my "if statement is obviously correct?


#2

Hi @devrunner48568

The "if" condition works only if the condition is true
Otherwise, it's the "else" who works

In your code your "if" is "false" , so it's your "else" who works

if(condition = true){
//program does this code
}else{
//program does this code
}

Read one more time the lesson

Hold on :wink:


#3

If you're trying to compare the values of the length of each string try this:

if ( myName.length >= myColor.length) {

All this lesson requires however is that you output to the console "I finished my first course!" So in reality you could just switch your console.log statements so that "I finished my first course!" is in the "else" statement:

else {
    console.log("I finished my first course!");
}