Robbing the mini mart, did i do this right?


#1

switch(cashier) {
    case "fight":
        var decision = prompt("are you good at fighting?","Yes,No").toUpperCase()
        var decision1 = prompt("are you an annoying person?","Yes,No").toUpperCase()
        if(decision === YES && decision1=== YES){
            console.log("you start laughing at the clerk and point at his turban. you punch the clerk in the face when he starts looking angry. since your good at fighting he's knocked out cold.")
        } else if (decision === NO && decision1 === YES){ 
            console.log("you punch the slightly indian looking cashier in the face. he stumbles backwards and starts yelling something in arabic or something you don't really know since you don't speak simoan or whatever race that prick is.")
        } else if (decision === YES && decision1 === NO){
            console.log("you punch the arab looking guy in the face knocking him out cold.")
        } else (decision=== NO && decision2 === NO) { 
            console.log("you punch the turban wearing jerk in the face, he stumbles back and stares in disbelief, then runs over to the phone and calls 911")
        break;
    case "rob":
var rob1 = prompt ("do you have a gun?","yes,no").toUpperCase()
var rob2 = prompt ("do you have a get away car?","yes,no").toUpperCase()
if(rob1=== YES || rob2 === YES) {
console.log("you point the gun at the cashier and begin yelling give me all the money in the drawer! After the arab guy empty's the drawer in to a bag and hands it to you you turn to the rest of the people in the store,\"empty your wallets\" after getting all the money you turn to the arab guy shoot him in the face and turn and run.")
} else if (rob1=== YES || rob2 === NO) { console.log("You run in shoot the arab cashier in the face and grab all the cash and are forced to walk with your loot since you weren't bright enought to plan a getaway car")
} else if (rob1 === NO || rob2=== YES) { console.log("you slide the cashier a note saying if she doesn't stuff the money in a bag you'll blow her brains out and then kill everybody.")
} else { console.log( you attempt to rob the place by sliding a note to the cashier but after several seconds you realize that she wasn't going to give you any money and probably pressed a silent alarm. you run out side only to get shot down like in GTA 5.)
}
        break;
    case "run"
    var run1 = prompt("is that your ex-girlfriend that just walked in?","yes,no")
    var run2 = prompt("did you forget the turkey in the oven?")
    if(run1 === YES && run2 === YES) {
        console.log("you sh*t yourself a little look to your left and you see a nearby shelf you slide to the edge of it and watch your ex walk over to the pizza's at the other end of the store. you quickly make your way to door only to run into a guy walking out with a drink. You quickly make it home after that fiasco and find the turkeys just fine.")
}else if (run1 === YES && run2 ===NO) { console.log (so there you are minding your own business when all of a sudden your ex girlfriend walks in. she notices you standing at the register waiting to get checked out and smiles and winks at you. you drop your groceries and gun her down. just kidding in actuallity you got pissed and spilled your drink on yourself.)      
    } else if (run1=== NO && run2 === YES) {
        console.log("you run out of the building in a panic like you stole something when in actuallity you left the thanksgiving turkey in the oven.you get home and the turkeys just fine. the mini mart franchise will now watch your every movment")
    } else if (run1===NO && run2=== NO){
        console.log("you can't seem to make up your mind so you close your eyes with one hand and spin in a circle until you get dizzy with the other hand pointed out.") 
    break;
default: 
    console.log("So instead of spiceing up the day you go home successful and bored")
}

It says unexpected token {


#2

As you can see in your formatted (colored) code, big chunks of the code are actually interpreted as string, You have to specifcally "escape" every single quotation mark in your strings, so that it doesn't brake the formatting, like this:

console.log("She wasn\'t going to give you any money")

Just put backwards slash before every single quotation mark. Also, what is the full error you get, usually it tells you on which line it found the error unexpected token in your case?


#3

it say unterminated template literal


#4

Also, add double quotation marks on your second else statement. You have to be very careful and make sure that every string (and string only) is inside double quotation marks.


#5

do i have to end all if statements with else? or is else if good enough? and i did that


#6

The else statements are optional. So you can have only if and else if statements (with no else) and everything will work fine.


#7

thank you for your help so far but do you know what it means by unterminated template literal?


#8

It means that you either have string without the opening double quotation marks or the closing quotation marks are missing.


#9

} else { console.log("you attempt to rob the place by sliding a note to the cashier but after several seconds you realize that she wasn\'t going to give you any money and probably pressed a silent alarm. you run out side only to get shot down like in GTA 5.")
}


#10

I guess codecademy is not PC, yes?