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;
}
24 Sep 2020 at 04:59 PM
0pnshow more
StorStor
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;
}

27 Sep 2020 at 12:25 PM
0pnshow more
TimTim
Share on FacebookShare on TwitterShare on LinkedInSend email
Follow us on Facebook & Twitter
2022 AnswerTabsTermsContact us