Not displaying printed strings till end


#1

I finished coding the game, but none of the console.logs will display until I have gone through every prompt. How do I make it so the console.logs print as I respond to the prompts? Thanks!

Here is my code:

confirm("I am ready to embark on an epic, awesome, splendiferous adventure!");

var age = prompt("How old are you?");

if (age < 13) {
console.log("you can play, but we take no responsibility if you get in trouble or die!")
}
else {
console.log("Welcome to 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 my game from 1-10, 10 being the best ever, and a 1 being super duper sad.");

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


#2

Ok do this.

For all of the prompts overlap it to a parseInt()

Like this:
var feedback = parseInt(prompt("Please rate my game from 1-10, 10 being the best ever, and a 1 being super duper sad."));

Tell me if it works.


#3

Okay, I just tried that on all the prompts and unfortunately no =/


#4

Ok can you show me your updated code. I will 100% work this out!


#5

thank you for your help!

Here is the updated code:

confirm("I am ready to embark on an epic, awesome, splendiferous adventure!");

var age = parseInt(prompt("How old are you?"));

if (age < 13) {
console.log("you can play, but we take no responsibility if you get in trouble or die!")
}
else {
console.log("Welcome to 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 = parseInt(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 = parseInt(prompt("Please rate my game from 1-10, 10 being the best ever, and a 1 being super duper sad."));

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


#6

Fixed a little bit of brackets, is this good now?

// Check if the user is ready to play!
confirm("I am Ready To Play!");

var age = prompt("Whats Your Age?")

    if(age>13){
     console.log("Enjoy!");   
    }
    else{
console.log("You are underage, we dont take any responsibili     ty");   
}

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{
   "Oh no! Bieber shakes his head and sings 'I set a pace, so I can race without pacing.'" 
}

var feedback = prompt("Rate this game out of 10");

if(feedback>8){
   console.log("Thank you! We should race at the next concert!");
   
}

else{
    console.log("I'll keep practicing coding and racing.");
}

#7

It still displays it all at the very end, rather than interacting with my responses =(


#8

This is a bug from codecademy, i dont know what else to tell you. I really wish i could help!


#9

aww okay - that's a bummer I was looking forward to seeing the final product.

well thank you so much Amanuel - I really appreciate you looking over my code and your willingness to help =) have a merry christmas!


#10

Merry Christmas!!!!!! Take a look at this for your present! :smile:


#11

I am having the same problem. My code executes but the console.log() doesn't print until after all prompts are finished. Has anyone else had (and fixed) this problem? I've had the same issue with JavaScript elsewhere (e.g html files) and haven't found a solution.


#12

Well, I'm not sure anymore, cause I passed out this lesson have some time. But It seems it is missing semi-colons after parenthesis.