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