What is wrong with my code


#1

I tried to freestyle this code and filled in my own name= Eli Raffles. Why did it not come up as "You have the same name as me?"

prompt("MyName")
if("MyName"==="Eli Raffles")
{
console.log("You have the same name as me!")
}
else
{console.log("You have a nice name!")}


#2

prompt("MyName")
if("MyName"==="Eli Raffles")
{
console.log("You have the same name as me!")
}
else
{console.log("You have a nice name!")}

It doesn't know what "MyName" is when you call it in the if statement, you need to declare a variable and assign the prompt's answer to that variable, like so:

var MyName = prompt("What is your name?");
if(MyName==="Eli Raffles")
{
console.log("You have the same name as me!");
}
else
{console.log("You have a nice name!");
}

You also forget some semicolons.