0
What is wrong in this code?Please help.
3 ответов
+ 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 ;