6th Oct 2019, 5:07 PM
Akshat Kumar Singh
Akshat Kumar Singh - avatar
3 Respuestas
+ 2
if (a>0){document.write("A positive number")}; else if(a<0){document.write("A negative number")}; else{document.write("0")}; when you put it on ; , JavaScript understands that you are completely terminating the function, and that's not what you want, you want it to try calling “else” if it doesn't call “if”, so the right code is: if (a>0){ document.write("A positive number") }else if(a<0){ document.write("A negative number") }else{document.write("0") }; only the last “else” should contain ;
6th Oct 2019, 5:20 PM
Wardy Spirit
Wardy Spirit - avatar
6th Oct 2019, 9:12 PM
Anthony Johnson
Anthony Johnson - avatar