Help! Where is my syntax error?


#1

var user = prompt ("You are walking home from school and you see a baby penguin in the middle of the road. He is in danger! Do you attempt to SAVE him risking your own safety, do you you RUN to get help, or SLAP yourself awake(PENGUINS?! This must be a dream).").toUpperCase();

switch(user) {
   case  'SAVE':
    var fast = prompt ("That was brave! or perhaps reckless... Are you fast(YES or NO?").toUpperCase();
    var agile = prompt("Are you agile?").toUpperCase();
    if (strong === 'YES' && agile === 'YES'){
    console.log ("Luckily you have the speed and agility to run after the baby penguin. You dart through traffic dodging and jumping over cars as you bring the little guy to safety. Yippee!");
    } else {
    console.log ("A car nearly misses you as you run to the rescue, suddenly a school bus comes out of nowhere and your toast! ouch! Well never know if the penguin lived to see another day...");
    }
    break;
    
case  'RUN':
    var fast = prompt ("safety first I always say! Are you a fast runner (YES or NO)?").toUpperCase();
    var talk = prompt ("Do you talk to strangers(YES or NO)?").toUpperCase();
    if (fast === 'YES' && talk === 'YES') {
    console.log ("You run as fast as you can to find help! You see a traffic conductor and urgently ask him for help. He agrees and together you run to save the baby penguin. Your new friend stops the traffic and you bring the little one to safety. Hooray!");
    } else {
    console.log("You run to go get help but you fail to find somebody who can save the baby penguin! You return to see if he is okay and he's gone! I guess well never know what happened...");
    }
    break;
    
case 'SLAP': 
    var feet = prompt ("You give yourself a slap! *whack!* It was all a dream! Did you watch Happy feet lastnight (YES or NO)?").toUpperCase();
    var planet = prompt ("Ohhhh! You watched Planet earth right (YES or NO)?").toUpperCase(); 
    if feet === YES || planet === YES){
    console.log ("Well I guess that makes sense... Maybe lay off the TV watching before bed...");
    } else {
    console.log (" Perhaps the penguin is your spirit animal and you feel trapped and in danger. Please seek professional help");
    }
    break;
    default:
    console.log("I DO NOT COMPUTE...I didn't understand your choice. Hit Run and try again, this time picking SAVE, RUN, or SLAP!");
}

#2

have a close look at

`if feet === YES || planet === YES){`


#4

if feet === 'YES' || planet === 'YES'){

didn't you see you need a ( bracket here


#6

Now I do!!! Thank you so much!


#7

most welcome........ :slight_smile:


#8

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