ELSEIF condition not working with IF and ELSE in Javascript

I would like to use ELSEIF statement to set a condition in Javascript, but it is not working. Would you please tell me what is incorrect ?

IF (value==1) {
var a = 1;
} ELSEIF (value==2) {
var a = 2;
} ELSE {
var a = 0;
}
0
give a positive ratinggive a negative rating
Hi,

To make it work you have to replace "ELSEIF" with "ELSE IF". ELSEIF is used in PHP. In Javascript is used ELSE IF function. The code should look like:


IF (value==1) {
var a = 1;
} ELSE IF (value==2) {
var a = 2;
} ELSE {
var a = 0;
}

Share on FacebookShare on TwitterShare on LinkedInSend email
1 answer
x
x
2024 AnswerTabsTermsContact us