0
is this valid for JS vars
Trying to rewrite my currect Code Exercise 'CHECK YOUR ZODIAC' to use 'Switch' So I write 'Conditions' as variable, example below, var star1 = month['January'] && day <= 20 || month['February'] & day <= 19; var result = ""; switch(result) { case star1 = document.write("sample); break; My concern is : Is it valid to write Condition as variable? thank you.. I'm still learning 🤗
4 Antworten
+ 4
No, it's still not how switch is used.
switch is for discrete choices, for example:
switch (day) :
case 1 :
case 2 :
case 3 :
....
case 10 :
alert("early this month");
break;
case 11 :
case 12 :
....
+ 2
It's not how switch is used.
0
sorry the question is confusing.. I edited the question
0
Ok, Thanks Gordon 😁 I will study it again..