0

Similar to my last post one of the exercises is to write an external JavaScript as below which produces the following output:

Iteration number: 1
Iteration number: 2
Iteration number: 3
Iteration number: 4
Iteration number: 5
Iteration number: 6
Iteration number: 7
Iteration number: 8
Iteration number: 9
Iteration number: 10

the problem is that I am only getting:

Iteration number: 10

function init()

{
   var panel=document.getElementById("panel");
   var i;
 
   for (i=1; i<11; i++)
   {
    panel.innerHTML="Iteration number: "+i+"<br>";
   }

}
window.onload=init;

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

3
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by vb.net_beginner
0

but to keep it simple ... you're just overwriting your value each iteration, you're not adding the next lines

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.