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"; }
   { panel.innerHTML="Power is Off"; }

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



same mistake as in your other function. you're overwriting the value, not adjusting it.