First Move lesson 4


#1

Hi,

a little stuck we have done everything that this lesson has asked but still getting an error, here is the code maybe you can see something that we have overlooked thank you.

// Check if the user is ready to play!
confirm (“ready for a game?”);

var age = prompt(“what is your age?”);

if (age >= 13)
{
console.log(“welcome to the game”);
}
else
{
console.log( “sorry you do not have permission.”);
}
console.log(“You are at a Justin Bieber concert, and you hear this lyric ‘Lace my shoes off, start racing.’”);

console.log(“Suddenly, Beiber stops ands says,‘Who wants to race me?’”);

var userAnswer = prompt(“do you want to race Beiber on Stage?”);

if (userAnswer ===“yes”)
{
console.log(“then get up here and get ready!”);
}
else
{
console.log(“sorry could you go to the back.”);


#2

What error

Also, invalid syntax, that won’t run at all, make sure that it’s possible to copy from the post and run it to get the same outcome as you’re asking about.


#3

when we hit save and submit it comes up with:
Oops, try again. Did you remember to console.log(“Suddenly, Bieber stops and says, ‘Who wants to race me?’”); ?


#4

Well if you hit Ctrl + F on this page and search for that text, then it’s nowhere in your code, so clearly you’re not doing that


#5

here is the newer code still same error

// Check if the user is ready to play!
confirm (“ready for a game?”);

var age = prompt(“what is your age?”);

if (age >= 13)
{
console.log(“welcome to the game”);
}
else (age <13);
{
console.log( “sorry you do not have permission.”);
}
console.log(“You are at a Justin Bieber concert, and you hear this lyric ‘Lace my shoes off, start racing.’”);
{
console.log(“Suddenly,Beiber stops and says,‘Who wants to race me?’”);
}
var userAnswer = prompt(“do you want to race Beiber on Stage?”);

if (userAnswer ===“yes”)
{
console.log(“then get up here and get ready!”);
}
else (userAnswer ===“no”);
{
console.log(“sorry could you go to the back.”);
}


#6

That still isn’t valid syntax (you can try this by copying it and pasting it and trying to run it)
Keep in mind that code isn’t prose, it should not be reformatted by the forum, it needs to be marked as code (buttons in the post editor do this)

Anyway, the error message you have still explains what’s wrong. You’re not printing that message. And you can verify this easily by doing a text search (something your browser supports with Ctrl f) for the text that the error message asks you to print. It does not occur in your code (so therefore it’s also not being printed)


#7

sorry tried to fix the syntax issues but sitting a wall now ahaha got any ideas on how to fix

// Check if the user is ready to play!
confirm (“ready for a game?”);

var age = prompt(“what is your age?”);

if (age >= 13)
{
print; console.log(“welcome to the game”);
}
else (age <13);
{
console.log( “sorry you do not have permission.”);
}
console.log(“You are at a Justin Bieber concert, and you hear this lyric ‘Lace my shoes off, start racing.’”);
{
print; console.log(“Suddenly, Bieber stops and says, ‘Who wants to race me?’”);
}
var userAnswer = prompt(“do you want to race Beiber on Stage?”);

if (userAnswer === “yes”);
{
console.log(“then get up here and get ready!”);
}
else (userAnswer === “no”);
{
print; console.log(“sorry could you go to the back.”);
}

if we remove from the else line (userAnswer === “no”)
it says that the else is missing an ; but when it is added it comes up with a whole bunch of errors


#8

If you have trouble with some particular language feature you might create a minimal program containing only that to make it easier to experiment with
and/or google for examples on that something (in this case an if-statement)
https://www.google.se/search?q=mdn+if+statement
Or go back to the place where you learned about it in the first place.

There aren’t all that many buttons in the post editor, if you hover over them it says what they do, allowing you to figure out which one to use to keep your code intact. It’s also just another thing that can be googled. Or work around it - post somewhere else where it’s kept intact and link to it. Problem solving is what programmers do (which is why I’m so keen on saying how you might be figuring things out rather than solving any particular problem for you)


#9

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