Invalid Response Loops



<Below this line, add a link to the EXACT exercise that you are stuck at.>

<Below this line, in what way does your code behave incorrectly? Include ALL error messages.>
What do I have to change so that instead of saying “I didn’t understand your choice. Hit Run and try again, this time picking FIGHT, PAY, or RUN!”, it will keep asking?


var troll = prompt(“You’re walking through the forest, minding your own business, and you run into a troll! Do you FIGHT him, PAY him, 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’) {
console.log(“You only need one of the two! You beat the troll–nice work!”);
} else {
console.log(“You’re not strong OR smart? Well, if you were smarter, you probably wouldn’t have tried to fight a troll. You lose!”);
case ‘PAY’:
var money = prompt(“All right, we’ll pay the troll. Do you have any money (YES or NO)?”).toUpperCase();
var dollars = prompt(“Is your money in Troll Dollars?”).toUpperCase();
if(money === ‘YES’ && dollars === ‘YES’) {
console.log(“Great! You pay the troll and continue on your merry way.”);
} else {
console.log(“Dang! This troll only takes Troll Dollars. You get whomped!”);
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’) {
console.log(“You got away–barely! You live to stroll through the forest another day.”);
} else {
console.log(“You’re not fast and you didn’t get a head start? You never had a chance! The troll eats you.”);
console.log(“I didn’t understand your choice. Hit Run and try again, this time picking FIGHT, PAY, or RUN!”);

<do not remove the three backticks above>


I hate the talks just stop sending me you deeds


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