mardi 17 septembre 2019

Compare 2 variables with 2 variables in Javascript

i just started studying Javascript and i'm trying to create a mini-game. I want to get the vocation of a character comparing if his health skill and attack skill are bigger than magic and speed, then he's a knight. But what i'm trying is not working.

if (hp1 && at1 > mg1 && sp1){
    document.querySelector('.badgesContainer .knight').style.display = 'block'
}
else{
    document.querySelector('.badgesContainer .druid').style.display = 'none'
    document.querySelector('.badgesContainer .knight').style.display = 'none'
    document.querySelector('.badgesContainer .paladin').style.display = 'none'
    document.querySelector('.badgesContainer .sorcerer').style.display = 'none'  
}

}

Aucun commentaire:

Enregistrer un commentaire