First of all, put the javascript code between a <script></script>
tag because javascript code will not run in an html <div></div>
tag.
Then, instead of x == 0||9||2
, use x == 0 || x == 9 || x == 2
.
Kindly indent your code for easier readability. The ||
operator looks for conditions on the let and right sides. 9
is not a condition, neither is 2
. When you put x == 9 || x == 2
, you’re saying check the condition on the left, if not true check the one on the right. If one is true, then we’re good to go.
solved If …Else If wont work [closed]