Skip to content

Instantly share code, notes, and snippets.

@Mortimer333
Created March 28, 2018 15:59
Show Gist options
  • Save Mortimer333/e9e9249b67d12940dd9d9c460dd77def to your computer and use it in GitHub Desktop.
Save Mortimer333/e9e9249b67d12940dd9d9c460dd77def to your computer and use it in GitHub Desktop.
Multiplication table in JavaScript (html)
<html>
<head>
<title>
JS page
</title>
<meta http-equiv= "Content-Type" content= "text/html; charset=utf-8">
<meta http-equiv= "Content-Language" content="pl">
<script>
function table(a)
{
document.write("<table border>")
document.write("<tr>"+"<td>"+"*"+"</td>")
for(i=1;i<=a;i++)
{
document.write("<td>"+i+"</td>")
}
document.write("</tr>")
for (k=1;k<=a;k++)
{
document.write("<tr><td>"+k+"</td>")
for (i=1;i<=a;i++)
{
document.write("<td>"+i*k+"</td>")
}
document.write("</tr>")
}
document.write("</table>")
}
</script>
</head>
<body>
<script type="text/javascript">
var a=prompt("How big?","")
eval(a);
table(a);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment