Help Needed With Switch function 'break'


#1

Hi, can anyone help me here, what am I doing wrong.

The code runs normally but I get the instruction 'Oops try again, Make sure to use a break statement with each case!'

var user = prompt ("You're going to buy groceries, someone blocks you and demands for your money, what do you do? Run, Fight, Give").toUpperCase(); 
switch(user) {
    case 'RUN':
        console.log("Sweet, keep running, but are you fast at running?");
        break;
    case 'FIGHT':
        console.log("Nice move, how good are you in fighting?");
        break;
    case 'GIVE':
        console.log("Really!!! You just give him without any resistance");
        break;
    default:
        console.log("I'm sorry, I don't know what you mean");
}


#2

Remember to include break; after the default case.


#3

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