I need help debugging :)


#1

:wink: :sob:

var troll = prompt("After you ate the pigs that army came back and saw you ate their pigs what do you do. PAY away, FIGHT them, or RUN?").toUpperCase();

switch (troll) {
case 'FIGHT':
var strong = prompt("How courageous! Are you strong (YES or NO)?").toUpperCase();
var smart = prompt("Are you smart?").toUpperCase();
if (strong === 'YES' || smart === 'YES') {
var rekted = prompt("You hide somewhere and throw rocks at them until they run away");
} else {
var notSmart = prompt("You're not strong OR smart? Well, You pay them and if you can't afford that you will be executed");
}
break;
case 'PAY':
var money = prompt("All right, we'll pay the army. Do you have any money (YES or NO)?").toUpperCase();
var dollars = prompt("Is your money in Pigs?").toUpperCase();
if (money === 'YES' && dollars === 'YES') {
var log = prompt("They kill you so that they get their money in pigs");
} else {
var REkt = prompt("They make you steal and hunt wild pigs for the next 10 years and your very unhappy");
}
break;
case 'RUN':
var fast = prompt("Let's book it! Are you fast (YES or NO)?").toUpperCase();
var headStart = prompt("Did you get a head start?").toUpperCase();
if (fast === 'YES' || headStart === 'YES') {
var damoreSpeed = prompt("you just ate and you slowly walk away but they chase you down");
} else {
var nospeed = prompt("You're not fast but you trick them into thinking you ran away on a horse");
}
break;
default:
var coin = prompt("I didn't understand your choice. Hit Run and try again, this time picking FIGHT, PAY, or RUN!");
}


#2

do you have a specific error, or are you simply looking to improve your code?

For some reason your return is a promp rather than an alert or console.log.

promp is asking for input with an alert message, alert() simply shows a message popup. Make sure that the end of all your conditions gives a console.log or an alert. You wouldn't be asking for input if it's the last one.