Design of code output questions... Very Curious


#1

The story heats up!

No Error message, just curious about the flow of console logs and interaction with the user.

I’m trying to clean up the output so instead of it printing in the console:

You can play, but you might need a permission slip, ask your folks.
You are at a Justin Bieber concert, and you hear this lyric 'Lace my shoes off, start racing.'
Suddenly, Bieber stops and says, ‘Who wants to race me?’

I instead want it to log

You can play, but you might need a permission slip, ask your folks.

You are at a Justin Bieber concert, and you hear this lyric ‘Lace my shoes off, start racing.’

Suddenly, Bieber stops and says, ‘Who wants to race me?’

This can be achieved with an \n correct?

ALSO… I’m trying to make it so that when the program asks the prompt of the user, it then prints just that part and follows with the next alert and prompt. Currently my code makes all the prompts and alerts happen one after another before printing anything on the console. Very confusing for the user playing. Did I miss something. Very curious about these details. Thanks!



// Check if the user is ready to play!

confirm("Ready for an adventure?");
var age = prompt("How old are you?");

if (age < 13)
{
    console.log("You can play, but you might need a permission slip, ask your folks.");
 }
else
{
    console.log("Great, with all that life experience, you should do smashingly well!/n");    
}

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


#2

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