Logical operators


Hey, when i input 5 and 5 i still get the else if output and not the else output. What am i doing wrong ?
hope u guys can help me :slight_smile:

var user = prompt("Are you ready to gith the goblin king ?").toUpperCase();
var power = prompt("How much power do u have ? (1-5)").toUpperCase();
var health = prompt("How much health do u have ? (1-5)").toUpperCase();

    case 'YES':
        if(power<=3 && health<=3){
            console.log("you are to weak and lose the fight");
        else if (power>=4 || health>=4){
            console.log("u almost got killed but made it");
        console.log("u nailed it !");
    case 'No' :
        console.log("you run away");
        console.log("We can't do that right now");


In your else if statement, your checking to see if power and health are greater than or equal to 4, which they are when you input 5.
Try changing this:

else if (power>=4 || health>=4)

To this:

else if (power<=4 || health<=4)


Ya but i want to check if "power" or "health" is 4 or higher. so only one of the two,

for example :
2 power and 1 health = if output
5 power and 3 health = else if output
2 power and 4 health = else if output
4 power 5 health = else output
5 power 5 health = else output.


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