Code your own Adventure 2 Batman style


#1

https://www.codecademy.com/en/courses/javascript-beginner-en-ZA2rb/0/5?curriculum_id=506324b3a7dffd00020bf661#

<Below this line, in what way does your code behave incorrectly? Include ALL error messages
Whenever I save and submit code for the SAVE option it says that SCARE is not defined.
Whenever I save and submit code for the FIGHT option it says that YES is not defined.
Whenever I save and submit code for INVESTIGATE it says that CALL is not defined.



var user = prompt("You are Batman flying around Gotham. You need to SAVE the firefighters, FIGHT the Arkham Knight, or INVESTIGATE the missing person report. What do you do?").toUpperCase()

switch(user) {
    case 'SAVE':
        var glide = prompt("You glide in and see 4 crooks beating the firefighter, do you SCARE the crooks or BEAT them?").toUpperCase()
        if(glide === SCARE || glide === BEAT)   {
            console.log("The crooks are terrified of you strength and either run in fear or crumple from your mighty blows!")
        }
        else    {
            console.log("Batman wants to either BEAT the criminals or SCARE them.")
        }
        break;
        
    case 'FIGHT':
        var find = prompt("You choose to Fight the Arkham Knight but he is nowhere to be found, do you try to find him?").toUpperCase();
        var tank = prompt("As you make this decision, 7 unmanned tanks roll onto the street. You realize that if you cripple his fighting force the Arkham Knight may be drawn out and forced to fight, do you fight the tanks?").toUpperCase();
        if(find === YES && tank === YES)    {
            console.log("You fight the tanks and take some damage, but you are succesful in drawing the Arkham Knight out, time to end this.");
        }
        else    {
            console.log("You can't very well fight the Arkham Knight if you don't want to find him or if you don't draw him out. you take so long to make this decision that the tanks eviscerate you.");
        }
            
        break;
        
    case 'INVESTIGATE':
        var trail = prompt("You find a trail of clues that leads into a potentially deadly situation, do you CALL the batmobile, or go on ALONE?").toUpperCase();
        if(trail === CALL)  {
            console.log("You call the batmobile and enter the situation with guns blazing only to find the villain has already left, time to continue to look for clues.");
        }
        else if(trail === ALONE)    {
            console.log("You choose to go on alone, and find that the villain has already left, time to continue to look for clues.");
        }
        else    {
            console.log("Batman wants to either go ALONE or CALL the batmobile, that's his style.");
        }
        break;
        
    default:
        console.log("Batman didn't recognize your choice, he has no time for mistakes.")
        break;
        
}



#2

Nevermind I figured out that each option within the if statements had to have quotes around them

ex:

if(glide === ‘SCARE’ || glide === 'BEAT)


#3

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