Whatever the Khushal has explain in its earlier post is absolutely right like that way you can achieve the single If condition with the Multiple condition criteria.
Here i will explain some IFElse related things which i feel to be clear with you.Each else clause belongs to the nearest preceding if statement. Because of this, it is not possible to have one catch all else clause act as a net for multiple if statements just because it follows a series of them. One final else clause can, however, act as a catch all net as long as each if statement, beginning with the second, is preceded by an else. The final else will then perform as a catch all because all the if statements are now attached to each other by the else statements.
Code:
if (name == "mini") {
alert("your name is mini")
}
else if (name == "harold") {
alert("your name is harold")
}
else if (name == "fred") {
alert("your name is fred")
}
else {
alert("Your name is not mini, harold or fred")
}
Bookmarks