+ 6
Can we use multiple else if
var course = prompt ("Enter course number"); if (course == 1) { document.write("<h1>HTML Tutorial</h1>"); } else if (course == 2) { document.write("<h1>CSS Tutorial</h1>"); } else if (course == 3) { document.write("<h1>JavaScript Tutorial</h1>"); } else {document.write ("No such course available"); } Is this valid?
19 Réponses
+ 6
Hello, Manoj!
That's right, this is a valid action
Please see the lesson from SoloLearn to understand the whole concept of "conditions"
https://www.sololearn.com/learn/JavaScript/1138/?ref=app
+ 9
You can use infinite number of:
- if statements
- else if statements
Else statements 'cannot' be used infinitely.
Only ONE else statement are allowed for ONE if statement.
+ 6
Yes this is valid. You can use also instead of if....else if, switch case construction.
+ 6
thats true... 99,99% you are right...
+ 5
Yes you can use as many else-if's as you want
+ 4
Yes, it is ok
+ 4
yes it is indeed valid
+ 4
Yes,why not?
This approach can be very helpful in checking many conditions at a time.
+ 3
yes it is ok
+ 1
This is ok but using switch will make it quiet easy
+ 1
yes you can use only one if and else statement but as many as you want else if statements in your code
+ 1
yes ,we can do bro....
+ 1
If else if makes code looks complex u can use switch case instead
+ 1
you can use multiple times if ..else if statement.. that's called nested loop
+ 1
Yes.You can use,but you can use switch better it.
0
ok thanks sir
0
yeah
0
Yes you can use as many If Else statements as you wish.
- 2
yes