+ 1
Why this code doesn't work?
var In = t; switch (In) { case a: break; document.write("t"); case t: document.write("e"); break; default: document.write ("Not recognized"); }
8 ответов
+ 8
Then you should keep "a" and "t" in double quotes.
+ 7
Wait, i saw your profile. You mean this code ?
https://code.sololearn.com/ctFrcH4nF2eK/?ref=app
The code type is Java not JavaScript and your code is in JavaScript.
Create a web code and put this code in its JS section.
+ 6
What is In ?
What is t ?
What is a ?
+ 6
Because if you won't put double quotes then it would be treated as a variable and if you will then it will be treated as a String (text)
+ 1
In is a variable defined upper.
t and a are possible values of variable In
+ 1
why? you think? I can try it. Might you're right
+ 1
var In = "t";
switch (In) {
case "a":
break;
document.write("t");
case "t":
document.write("e");
break;
default:
document.write
("Not recognized");
}
still it doesn't work :(
+ 1
now it works. thx for help