How would you use a switch case when you need to test for a or b in the same case?
switch (pageid) {
case "listing-page":
case "home-page":
alert("hello");
break;
case "details-page":
alert("goodbye");
break;
}
How would you use a switch case when you need to test for a or b in the same case?
switch (pageid) {
case "listing-page":
case "home-page":
alert("hello");
break;
case "details-page":
alert("goodbye");
break;
}
if (["listing-page", "home-page"].indexOf(pageid) > -1)
alert("hello");
else if (["exit-page", "logout-page"].indexOf(pageid) > -1)
alert("Good bye");
You can do that for multiple values with the same result