<head>
<script>
function whammo()
{
var i = 1;
while(i<=5)
{
document.write("<h6>Test</h6>");
i=i+1;
}
}
</script>
</head>
<body>
<div id='page'></div>
<script>
document.getElementById('page').innerHTML = whammo();
</script>
</body>
The whammo function is to return 5 h6 Tests to be displayed, but it returns the following: undefined Test Test Test Test Test
I did my testing here: http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_elmnt_innerhtml
Why is undefined being returned?