Multiple case options


#1

Continuing the discussion from More practice with switch:


https://www.codecademy.com/en/courses/javascript-beginner-en-qDwp0/1/3?curriculum_id=506324b3a7dffd00020bf661


Hey people, I was putting more practice on the switch and the case commands and came across the use of the || sign as a way of separating multiple alternatives with a similar response/log within a case. However ive been trying to apply it in my codes but it isn't working, instead it returns the default log which is "That month is not on my list" as seen in the code below.
Would you happen to understand why this is happening or is there a different alternative to doing what I am trying to do?
Thanks


var answer = prompt("Enter your month of birth to see how many days are in it","Enter the month of your birth here");

switch(answer) {
  case 'January' || 'March' || 'May' || 'July' || 'August' || 'October' || 'December':
    console.log("There are 31 days in this month.");
    break;
  // Add your code here!
  case 'February':
    prompt ("Depends, is it a leap year?") 
        if (prompt = "yes") {
            console.log ("Then your month of bith has 29 days");
        }
        else {
            console.log("Then your month of birth has 28 days");
        }
    break;
  case 'April' || 'June' || 'September' || 'November':
      console.log ("There are 30 days in this month.");
      break;
  default:
    console.log("That month is not on my list");
}


#2

if you saw that topic, you should have seen you use fall-through to simulate ||:

pageid="home-page"
switch (pageid)
{
    case "listing-page":
    case "home-page":
        alert("hello");
        break;
    case "details-page":
        alert("goodbye");
        break;
}

#3

Thanks, the code works now.


#4