4.switch -> ReferenceError: Invalid left-hand side in assignment <-


#1



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


ReferenceError: Invalid left-hand side in assignment


Not sure what is wrong



var user = prompt("After a busy day, you go for a stroll and an ogre finds you. What do you do? FIGHT, RUN or NEGOCIATE?").toUpperCase();

switch(user) {
    case 'FIGHT':
        var strong = prompt("How courageous! Are you sure you are strong enough?").toUpperCase();
        var weapon = prompt("By any chance... do you carry a weapon?").toUpperCase();
        
        if (strong === "yes" && weapon = "yes") {
            console.log("Whoa! Dead ogre");
        } else {
            console.log("Though luck this evening...");
        }
        break;
    
    case 'RUN':
        var fast = prompt("Running seems like a good idea. Are you fast?").toUpperCase();
        var hide = prompt("Seems legit. Do you know a hiding place?").toUpperCase();
        
        if (fast === "yes" || hide === "yes") {
            console.log("Pfew. You barely made it..."); 
        } else { 
            console.log("Sorry. Not a good day for sports...");
        }
        break;
    
    case 'NEGOCIATE':
        var smart = prompt("Good luck with that. Are you smart enough to trick an ogre?").toUpperCase();
        var gift = prompt("Can you offer him something of value to him?").toUpperCase();
        
        if (smart === "yes" || gift === "yes") {
            console.log("Such a great move!"); 
        } else {
            console.log("Guess not that smart...");
        }        
        break;
    
    default:
        console.log("I'm not sure what that means. Try again, please");
     
};


#2

this line:

if (strong === "yes" && weapon = "yes")

you use a single equal sign, which means assign instead of two or three equals sings for compare


#3