Break Statement for Each Case


#1

Oops, try again.
Make sure you have a break statement for each case.

// Write your code below!
question = prompt("This is a question?");

switch(question) {
case 'it is?':
console.log("case 1");
break;
case 'are you sure?':
console.log("case 2");
break;
case 'you do not sound positive':
console.log("case 3");
break;
default:
console.log("default case");
break;
}


#2

Please provide a link to the lesson so we can test your code. Thank you.


#3

I had the same issue on the lesson before this one. It took over an hour before my code was accepted.

https://www.codecademy.com/courses/javascript-beginner-en-qDwp0/1/4

Thank you for the fast reply!


#4

The SCT for this exercise is looking for the word case and counting how many breaks it finds. If the two counts don't match, it throws the error.

Be sure your code only has the actual case and break, and do not use either word outside of that.

var question = prompt("This is a question?");

switch(question) {
case 'it is?':
    console.log("# 1");
    break;
case 'are you sure?':
    console.log("# 2");
    break;
case 'you do not sound positive':
    console.log("# 3");
    break;
default:
    console.log("default");
}

#5

Passed! Thank you again.