Code falls through to default, why?


#1

Hello,
My output is correct but it always additionally falls through to the default.
For example, my input to "prompt" is love, which outputs as
OR
default
Is this because I don't have two inputs?

var user = prompt("pick either love or not").toUpperCase();

switch(user){
case "LOVE":
if(user || user){
console.log("OR");
}
else{
console.log("else");
}
break;
case "NOT":
if(user && user){
console.log("AND");
}
else{
console.log("else");
}
default:
console.log('default');
}


#2

That is just the console/codecademy running a script to check your code. You will not have this when you run this code outside of CC, or in another exercise. You did forget the break at the end of case "NOT":`


#3

So, essentially, the code runs all the way through and always prints out the default regardless?
If this truly is the case, most learners may think they have done it wrong, causing them to spend more time than necessary trying to figure out where they went wrong, when in fact, their work is correctly coded.


#4

No, codecademy runs a a number of test to see what the outcome is, to validate your code is correct.

In a few exercises yes, maybe, i don't know. Or i missed something in your code, but don't think so


#5

thanks for the response!


#6

Yeah! Plus, I didn't get to play my game :(.