Code your own adventure! (PROBLEM COMPREHENDING WHAT HAPPENED)


#1


Hi! I'm already done with this lesson (Code your own adventure). and the code below works just fine (I think.. no error message showed up).


But I'm quite confused with the results. Are all the prompt commands supposed to pop up before the console.log?


// Check if the user is ready to play!
confirm("Are you sure you want to play this game?");

var age= prompt("What's your age?");
if (age < 13)
{ console.log("Sorry but you're too young for this game");
}
else
{ console.log("Welcome! goodluck playing this shit");
}

console.log("You are at a Justin Bieber concert, and you hear this lyric 'Lace my shoes off, start racing.'");
console.log("Suddenly, Bieber stops and says, 'Who wants to race me?'"); 
var userAnswer= prompt("Do you want to race Bieber on this stage?");
if (userAnswer = "yes")
{ console.log("You and Bieber start racing. It's neck and neck! You win by a shoelace!");
}
else (userAnswer = "no")
{ console.log("Oh no! Bieber shakes his head and sings'I set a pace, so I can race without pacing.'");
}
//Feedback
var feedback = prompt("rate the game from 1-10");
if (feedback > 8)
{console.log("Thank you! We should race at the next concert!");
}
else (feedback < 8)
{console.log("I'll keep practicing coding and racing.");
}


#2

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