Switch - only returns the default case


#1

// Write your code below!
var location = prompt("Where do you want to vacation?");
switch(location) {
case 'beach' :
console.log("Don't get sand in your cracks!");
break;
case 'vegas' :
console.log("Don't loose all your money!");
break;
case 'ohio' :
console.log("Relatives & fish begins to smell after 3 days!");
break;
default :
console.log("Really do something!");
}


#2

Ok @cgainer i investigated your problem and it seems to be wierd.... when i console.log() location it gave me this codecademy location. This is probably a codecademy issue not yours.. So if you change location to something else it should work.. Like this:

var something = prompt("Where do you want to vacation?");
switch(something) {
case 'beach' :
console.log("Don't get sand in your cracks!");
break;
case 'vegas' :
console.log("Don't loose all your money!");
break;
case 'ohio' :
console.log("Relatives & fish begins to smell after 3 days!");
break;
default :
console.log("Really do something!");
}

#3

I have past to lesson but it is just not in this chapter. I run into same same issue in the next chapter. I have written case constuct in multiple languages. Can someone please tell me where I am going wrong?


#4

Can you show us your code? Otherwise we cant help you..


#5

I changed the variable name from location to vacLoc and that solved the issue. Thanks


#6

hey pls any one solve this problem
var answer = prompt("Add your question here!","nothing");

switch(answer) {
case 'nothing':
console.log("No question!");
break;
case 'something';
console.log("Still question!");
break;
// Add your code here!
default :
console.log("Really do something!");
}


#7

Maybe tell us what the problem is first?


#8