Make sure to use a break statement with each case!


#1

Hi all, this is my problem, i entered my code but when i hit Save & Submit, it says;"Oops, try again. Make sure to use a break statement with each case! "
For me it’s ok, i’ve already gone through ALL code, however i don’t understand where’s the mistake???

//code your own adventure

/*it asks our user what he or she wants to do.
store the result of using prompt in a variable so we can use the user’s response to influence.

.toUpperCase() function
converted the user’s answer to ALL CAPS before saving it in the answer variable. This helps eliminate problems that might crop up if your program tests for ‘YES’ but your user typed in ‘yes’ or 'Yes’at the program does.

*/
var user = prompt(“Name?”).toUpperCase();//Question to the user

//switch statement that will test for several different cases (that is, different possible user inputs), Create as many as you like! (Do at least three.)
switch(user) {
case ‘BUSTER’:
console.log(“Hey, brother!”);
break;
case ‘GOB’:
console.log(“I’ve made a huge mistake.”);
break;
case ‘STEVE’:
console.log(“Steve Holt!”);
break;
default:
console.log(“I don’t know you!”);
}


Code your own adventure2
#2

I don’t recognize any errors in your syntax nor logic. You could try adding a break in the default clause.

I’m guessing that is what worked in this example:
https://www.codecademy.com/en/forum_questions/51392846679aea7b290097f1


#3

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