Last active
December 10, 2015 19:48
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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