Story/Prompt/Print Order


#1


https://www.codecademy.com/en/courses/javascript-beginner-en-x9DnD/0/7?curriculum_id=506324b3a7dffd00020bf661


I am not having any errors in my code per say, I have completed the lesson but when I submit my code it runs all of the prompts for age, racing and rating the game first and then it spits out all of the text, including the feedback all at once at the end. Is there a way that I can have the program print text, prompt, print text prompt, etc?


confirm("Click OK when you are ready to play!")

var age = prompt("What's your age?")


if(age < 13) {
    console.log("You may be too young for this game, play at your own risk!");
}
else {
    console.log("Enjoy playing the game!")
}

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 stage?")

if(userAnswer === "Yes") {
    console.log("You and Bieber start racing. It's neck and neck! You win by a shoelace!") 
}
else {
    console.log("Oh no! Bieber shakes his head and sings 'I set a pace, so I can race without pacing.'")
}

var feedback = prompt("Please rate this game from 1-10; 1 being a complete dumpster fire and 10 being the best game you've ever played!")

if(feedback > 8) {
    console.log("Thank you! We should race at the next concert!")
}
else {
    console.log("Okay... I'll keep practicing coding and racing.")
}


#2

For this exercise, not really. JavaScript dialogs are taking precedence to everything else. Code is frozen when dialogs are open. All logging is held in abeyance until the dialogs are finished.


#3

Gotcha, makes sense, thanks for the reply!


#4

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