0

Hey Folks I am just starting out with JavaScript and am following the resource book for the course I am on.

One of the exercises is to write an external JavaScript as below which produces the following output:

Power is Off
Number is Ten

the problem is that I am only getting:

Number is Ten

function init()

{
   var panel=document.getElementById("panel");
   var flag=false;
   var num=10;

   if (flag)
   { panel.innerHTML="Power is On"; }
   else
   { panel.innerHTML="Power is Off"; }

   if (num === 5)
   { panel.innerHTML="<br>Number is Five"; }
   else if (num === 10)
   { panel.innerHTML="<br>Number is Ten"; }
   else
   { panel.innerHTML="<br>Number is Neither Five or Ten"; }

}

window.onload=init;

Edited by peter_budo: Keep It Clear - Do use code tags when posting any code

2
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by vb.net_beginner
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.