Putting in the Logical operators: Error: Invalid left hand assignment!?!?!?


#1



Hi all,

I was wondering if you could tell me whats wrong with my code. I thought it looked right but obviously I'm wrong hahaha. Don't judge me for the variable names :wink:

EDIT: I've figured out the problem :slight_smile:


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


var user = prompt("Do you want to PUNCH the troll, KISS the troll or just RUN away from the troll").toUpperCase();

switch(user){
    case "PUNCH":
        var strength = prompt("Do you have the strength to knock him out?(YES or NO)").toUpperCase();
        var skill = prompt ("Do you have the skill to evade counters?(YES or NO)").toUpperCase();
        if(stength == "YES" && skill == "YES"){
            console.log("You got him right in the chops");
        }else if(strength = "YES" || skill = "YES"){
            console.log("Well, you might do well, you might not");
        }else{
            console.log("Urmmm good luck then!");
        };
        break;
    
    case "KISS":
        var sexAppeal = prompt("Do you have the sex appeal for a troll (YES or NO)").toUpperCase();
        if(sexAppeal = "YES"){
            console.log("Go for it, nobody is judging you here");
        }else{
            console.log("What the heckers you doing");
        }
        break;
    
    case "RUN":
        var training = prompt("Have you been training with Usain Bolt (YES or NO)").toUpperCase();
        if(training = "YES"){
            console.log("You're going to be fine");
        }else{
            console.log("The troll find and it will lick you");
        };
        break;
    
    default:
        console.log("You're just going to stand there.....");
    
    
}


#2

Hi inside all your if statement you should change the = with === also in the else if statement