+ 5
What is the difference between IF,ELSE and ELSE IF in java script?
Can anyone explain it?
6 Réponses
+ 2
if( if any thing here true ){
do the thing here.
} else if ( else if other thing true ){
Do the function here
} else {
Do if every booleans above false
}
+ 4
IF
ELSE IF (×any number of times)
ELSE
Basically you're trying to get various statements to be tested in a specific order. ELSE is like a last resort when all statements fail to return True.
+ 4
imagine there is a basket with two color balls(red and green) and you picked one
if(col==“red”){alert(“red”)}
else if(col==“green”){ alert “green”}
else { alert(“color is neither green nor red”} //if neither first or second are true
+ 1
example:
if(5>6){
alert(5)
} else if (5<6){
alert(6)
} else {
alert("nothing ")
}
+ 1
Thanks for answering
0
u r wlc bro
Just keep learning 😉