mercredi 26 septembre 2018

java script if condition with multiple values [duplicate]

This question already has an answer here:

I got a role from the back-end If it is equals to "admin" , "staff", "manager" it should go to the if part of the block. otherwise it should go to the else part of the block.

let role = "restaurant";

if(role === "admin" || "manager" || "staff"){
  console.log("IF PART")
  console.log(role)
}
else{
  console.log("ELSE PART")
}

In this scenario it comes to if part. What's wrong with my code?

Any help

Thanks in advanced!

Aucun commentaire:

Enregistrer un commentaire