Not sure why this code doesn't work - simplest example I can think of
The console shows the output I’m expecting but I’m getting the “Oops. Try again” message.
// Write your code below!
var answer = prompt ("Enter the case number");
switch(answer){
case 'one':
console.log ("good one");
break;
case 'two':
console.log ("not so good");
break;
case 'three':
console.log ("oof! thats bad... very bad");
break;
default:
console.log ("nice. good case, eh?");
break;
}
Answer 527c0de0548c354cbe000015
Your prompt() is correct, and your switch() is almost correct but for one thing: default does not get a ‘break’. However on testing, I still passed with it in the code, so this is not the issue. I also tested if the while space in the console.log () statements is the cause. Passed again.
After testing your code line by line, it comes down to the default case. For some reason the SCT is seeing the word ‘case’ and thinking it is code, not text. Change the to ‘good-case’ or something else without the word, ‘case’.
4 comments
turns out - the exercise didn’t want me to add the var line at the top… just the case statement. when I deleted it I could continue. Thank you for your response.
This would indicate buggy exercise behavior, which will need to be reported. I’m on it.
This issue is still occurring fyi.
still ocurring..
Popular free courses
- In this SQL course, you'll learn how to manage large datasets and analyze real data using the standard data management language.
- Beginner Friendly.4 Lessons
- Learn how to use JavaScript — a powerful and flexible programming language for adding website interactivity.
- Beginner Friendly.11 Lessons
- Start at the beginning by learning HTML basics — an important foundation for building and editing web pages.
- Beginner Friendly.6 Lessons