Skip to content

Instantly share code, notes, and snippets.

@paulcook
Last active December 10, 2015 19:48
Show Gist options
  • Save paulcook/4483724 to your computer and use it in GitHub Desktop.
Save paulcook/4483724 to your computer and use it in GitHub Desktop.
A "Fizz Buzz" solution in javascript and html generating result in html table
<html>
<head>
<title>Three Five</title>
</head>
<body>
<table border="1">
<thead>
<tr>
<th>Int</th>
<th>Divisble by</th>
</tr>
</thead>
<tbody>
<script type="text/javascript">
for( i=1; i <= 100; i++ ){
document.write("<tr><td>"+i+"</td>");
if( i % 15 == 0 ){
document.write("<td>Divisble by both 3 and 5</td>");
}else if( i % 5 == 0 ){
document.write("<td>Divisble by 5</td>");
}else if( i % 3 == 0 ){
document.write("<td>Divisble by 3</td>");
}else{
document.write("<td>Divisble by neither 3 or 5</td>");
}
document.write("</tr>");
}
</script>
</tbody>
</table>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment