I've included the HTML code to give the whole picture of what I am trying to understand.
<html>
<head>
<title>Echo App</title>
</head>
<body>
<p>Echo</p>
<p>Say what? <input id="sayThis" size="40" /></p>
<p>How many times?
<select id="howMany">
<option value="1">1</option>
<option value="5">5</option>
<option value="10">10</option>
<option value="20">20</option>
</select></p>
<p><button onClick="doLoop()">Do it!</button></p>
<p><div id="results"></div></p>
<script type="text/javascript" language="javascript">
function doLoop() {
var sayWhat = document.getElementById("sayThis").value;
var maxLoop = document.getElementById("howMany").value;
var str = ""; // where we'll store our output temporarily
for (var i=1; (i<=maxLoop); i++) {
str = str + i + ":" + " " + sayWhat + '<br>';
}
document.getElementById("results").innerHTML=str;
}
</script>
</body>
</html>
How would the code be written out for this use of 'str'
str = str + i + ":" + " " + sayWhat + '<br>';
And, more especially, how would the code be written out for this use of 'str'
document.getElementById("results").innerHTML=str;
I look forward to your replies/answers. Thank you.