Need help with JS conclusion code


#1

Hi there,
For the life of me, I can't figure out what I am doing wrong for my if/else statement. I've looked up other answers in the forum and still can't quite get it. Here is my statement..

var myName="Monique";
console.log(myName);
if ("myName".length >= 7) {
console.log("I finished my first course!");
}
else {
console.log("Ooopss");
}

Any guidance would be greatly appreciated :smile:


#2

Hey there!

You used your variable "myName" correctly on the second line and then on the third line you did something differently :relaxed:


#3

oh!! was i supposed to leave off the quotes??
:smile:
ill try that!


#4

aahhh tried that and still no go lol. ill keep thinking!


#5

Are you sure? Can you post the code again with the replacement you made?


#6

sure thing.. one sec!


#7

here is what i posted the second time:

var myName="Monique";
console.log(myName);
if (myName.length >= 7) {
console.log("I finished my first course!");
}
else {
console.log("Ooopss");
}


#8

What is the error it says? Because right now it is correct and it runs the first console.log "I finished my first course"


#9

error says:
Oops, try again. It looks like you didn't log the correct string to the console! Make sure to use exactly the string shown.

but it returns the right result in the result window! confused.... :open_mouth:


#11

sorry-

i deleted line 3 and it worked
var myName="Monique";

if (myName.length >= 7)
{
console.log("I finished my first course!");
}
else
{
console.log("I messed up");
}

not sure why the console.log threw it off that much tho!


#12

yeah, the courses are strict on their spelling sometimes, or even the resulting output. lol
especially if you type out the text they want you to put in, often i get snagged because of a missing punctuation in the text.


#13

makes total sense- thank you both for your help!! i really appreciate it- i won't add extra junk from now on lol :smile: