How would you use a switch case when you need to test for a or b in the same case?
switch (pagei
Forget switch and break, lets play with if. And instead of asserting
if(pageid === "listing-page" || pageid === "home-page")
lets create several arrays with cases and check it with Array.prototype.includes()
var caseA = ["listing-page", "home-page"];
var caseB = ["details-page", "case04", "case05"];
if(caseA.includes(pageid)) {
alert("hello");
}
else if (caseB.includes(pageid)) {
alert("goodbye");
}
else {
alert("there is no else case");
}