These two switch statements are the same, other than the use of console.log. When outputting the result to the chrome console I get two different results. The first one outputs:
this is the one
while the second outputs:
1
this is the one
Why is that?
const q = 1;
switch (q) {
case '1':
answer = "one";
case 1:
answer = 1;
case 2:
answer = "this is the one";
break;
default:
answer = "not working";
}
console.log(answer);
const q1 = 1;
switch (q1) {
case '1':
console.log("one");
case 1:
console.log(1);
case 2:
console.log("this is the one");
break;
default:
console.log ("not working");
}