Skip to content

Instantly share code, notes, and snippets.

@jpatel3
Created August 5, 2012 16:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jpatel3/3265860 to your computer and use it in GitHub Desktop.
Save jpatel3/3265860 to your computer and use it in GitHub Desktop.
JavaScript Multiplication
<html>
<head>
<title>10*10 Multiplication Matrix</title>
</head>
<body>
<table border="2" cellspacing="0" >
<script language="javascript">
//Width
x=10
//Height
y=10
//Use prompt on above if you want dynmic
//Loop through height
for( i=0; i<=y; i++)
{
document.write("<tr>");
for( j=0; j<=x; j++)
{
//First row
if(i == 0)
document.write("<th>"+j+"</th>");
//first column
else if(j == 0)
document.write("<th>"+i+"</th>");
//Multiplication
else
document.write("<th>"+(i*j)+"</th>");
}
document.write("</tr>");
}
</script>
</table>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment