My code is not running as expected


#1

https://www.codecademy.com/en/courses/javascript-beginner-en-ZA2rb/0/5?curriculum_id=506324b3a7dffd00020bf661

Hi,

I seem to be getting only the default result ( Please let me know when you plan to visit? )when i type both Weekday and Weekend options.Please see my code.
In other words only the cases; default and undecided are running as expected.

I am not sure what is wrong with the code???


var user = prompt("When are you visiting us? is it during the Weekday, Weekend or are you still undecided?").toLowerCase()
switch(user){
    case 'Weekday':
        // your what to do
        var holiday = prompt("Is it a public holiday? (Yes or No) ?").toLowerCase();
        var relHoliday = prompt("Is it a religious public holiday ? (Yes or No ?)").toLowerCase();
        if(holiday === 'Yes' && relHoliday  === 'No'){
            console.log("Great! ill be home. See you then");
        }else{
            console.log("Im afraid ill be at the Parish");
        }
      break;
     case 'Weekend':
        // your what to do
        var sunday = prompt("is it on Sunday? (Yes or No)?").toLowerCase();
        var relHoliday = prompt("Is it a religious public holiday ? (Yes or No ?").toLowerCase();
        if(sunday === 'Yes' || relHoliday === 'Yes'){
            console.log("Im afraid ill be at the Parish");
        }else{
            console.log("Great! ill be home. See you then"); 
        }
      
        break;
     case 'undecided':
        // your what to do
        console.log("Please let me know as soon as you decide");
        break;
    default:
    console.log("Please let me know when you plan to visit?");
}


#2

Using toLowerCase() on this line converts all your responses to lowercase letters. Your cases start with capital letters. See the problem? Check your other prompts and cases as well.


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.