topical media & game development
basic-javascript-03-ch3-q4.htm / htm
<html>
<body>
<script language="JavaScript" type="text/javascript">
function writeTimesTable(timesTable, timesByStart, timesByEnd)
{
for (;timesByStart <= timesByEnd; timesByStart++)
{
document.write(timesTable + " * " + timesByStart + " = " +
timesByStart * timesTable + "<br>");
}
}
var timesTable;
while ( (timesTable = prompt("Enter the times table",-1)) != -1)
{
while (isNaN(timesTable) == true)
{
timesTable = prompt(timesTable + " is not a valid number, please retry",-1);
}
if (timesTable == -1)
{
break;
}
document.write("<br>The " + timesTable + " times table<br>");
writeTimesTable(timesTable,1,12);
}
</script>
</body>
</html>
(C) Æliens
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.