Simple Javascript Crashes Page?


#1

The page states: "In line 1, fill in a condition that will evaluate to false
Fill in some code to run in the else portion (this will run if the condition is false). Use console.log for this part"

I have created a simple length statement that evaluates to false, however upon running this my page crashes. There is obviously no loop and on my alt account I have already finished Javascript, does anyone see an issue? (It is not semicolons)

if ("harden".length >= 7 )
{
console.log("Let's go down the first road!")
}
else console.log("You have a short name!")
{
// What should we do if the condition is false? Fill in here:

}


#2

console.log should be inside the curly braces like below

else 
{
// What should we do if the condition is false? Fill in here:
console.log("You have a short name!")
}

#3

Wow man, thanks. That should have been completely obvious. :wink:


#4

Aside:

Not to be cynical, but expect the obvious to escape us on more occasions than one. Before pulling one's hair out, read the code backwards, from end to beginning. Many times the obvious jumps right out when we are not following our normal eye track.