Bieber Game JS


#1

Hello everyone! So i'm left wondering what could've gone wrong with my code.
prompt seems to be prompting one after the other, instead of showing
1st -confirm msg box
2nd -prompt to enter age
3rd it shows the if else
4th it will show the bieber phrases
5th bieber asks to race
6th (prompt should be showing answering "yes" but didnt because they showed after the 1st prompt)
6th (prompt should be showing for feedback but didnt because they showed after the 1st prompt)

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

var age = prompt("What is your age?");

if(age < 13){
console.log("You are allowed to play but you take no responsibility");
}else{
console.log("Play on!");
}

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 ot 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("Give us your feedbacks 1-10!");

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


#2

Seems to work fine to me!

Only issue I see... You never convert feedback's value into an integer. Just its length, which it will NEVER be, unless I put something in with 8 digits.


#3

CODE LIKE THIS:-
// Check if the user is ready to play!
confirm("Are you ready to play?");
var age = prompt("What's your age?");
if(age<13){
console.log("Allowed to play but no responsibility")
}
else{
console.log("Play on!")
}
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("Give us your feedback 1-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.")
}

If you find it useful then don't forget to like my post.


#4

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