Skip to content

Instantly share code, notes, and snippets.

@capitalJT
Last active August 29, 2015 14:05
Show Gist options
  • Save capitalJT/47d9b351ddc54f7d03d9 to your computer and use it in GitHub Desktop.
Save capitalJT/47d9b351ddc54f7d03d9 to your computer and use it in GitHub Desktop.
[if else statements using the modulo operator]// source http://jsbin.com/biqif/3
for(i = 100; i; i--){
if(i % 3 === 0){
console.log("fizz " + i);
} else if(i % 5 === 0){
console.log("buzz " + i);
}
if(i % 3 === 0 && i % 5 === 0){
console.log("buzzbuzz " + i);
}
}
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="[if else statements using the modulo operator]" />
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
This is just a comment
<script id="jsbin-javascript">
for(i = 100; i; i--){
if(i % 3 === 0){
console.log("fizz " + i);
} else if(i % 5 === 0){
console.log("buzz " + i);
}
if(i % 3 === 0 && i % 5 === 0){
console.log("buzzbuzz " + i);
}
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment