.toUpperCase bugs my code (SOLVED)


I finished all sections for the code your own adventure 2. However, I noticed that when my prompt has .toUpperCase in the end, it makes the code go straight to the default, even when I properly type in the cases in my switch code. Here is the var and switch:

var user = prompt("Will you listen?").toUpperCase();

switch(user) {
case 'Blog': if (user && user) {
{ }
console.log("I prefer the blog");
case 'Video':if (user || user) {
else { }
console.log("I prefer the videos");
case 'In person': if (user || user) {
else { }

console.log("I prefer to meet in person");
default: console.log("this is the default");


When I remove the touppercase, I get all parts of the switch working right. Why does it do that?


It doesn't work because you changed the prompt's answer into UPPERCASE and then base all of your cases on non UPPERCASE things. All of your cases need to be uppercase:

Should be

case 'BLOG': 
 if (user && user) {



Got it, tested it, changed it, it works now.

I must have read the explanation wrong then. I thought it only referred to the user input when answering a prompt. I didn't expect it to also affect how I write the cases. Thank you.



Your welcome. Now could you please mark this topic as solved so no one else responds? Thanks.


Thank you! Your answer here helped me, too. 😊