Skip to content

Instantly share code, notes, and snippets.

@AminBusiness
Created November 9, 2018 01:51
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 AminBusiness/f9010e7e5793153b1bfa1599594c4f4a to your computer and use it in GitHub Desktop.
Save AminBusiness/f9010e7e5793153b1bfa1599594c4f4a to your computer and use it in GitHub Desktop.
<script id="jsbin-javascript">
//Challenge 6: FIZZBUZZ
//Write a program that prints all of the numbers from 1 to 11 in multiples of 3,
//instead of the number, print "fizz", for multiples of 5 print "buzz", for numbers
//Which are mutiples ofboth 3 and 5, print "Fizzbuzz".
function fizzbuzz()
{
//Loops through 1 - 100
for(let i = 1; i <= 100; i++)
{
if(i % 3 === 0 && i % 5 === 0)
{
console.log('FizzBuzz')
}
//If there is a remainder of 3
else if(i % 3 === 0) {
console.log('Fizz')
} else if(i % 5 === 0)
{
console.log('FizzBuzz')
}
else
{
console.log(i);
}
}
}
const output = fizzbuzz('')
console.log(output);
</script>
<script id="jsbin-source-javascript" type="text/javascript">//Challenge 6: FIZZBUZZ
//Write a program that prints all of the numbers from 1 to 11 in multiples of 3,
//instead of the number, print "fizz", for multiples of 5 print "buzz", for numbers
//Which are mutiples ofboth 3 and 5, print "Fizzbuzz".
function fizzbuzz()
{
//Loops through 1 - 100
for(let i = 1; i <= 100; i++)
{
if(i % 3 === 0 && i % 5 === 0)
{
console.log('FizzBuzz')
}
//If there is a remainder of 3
else if(i % 3 === 0) {
console.log('Fizz')
} else if(i % 5 === 0)
{
console.log('FizzBuzz')
}
else
{
console.log(i);
}
}
}
const output = fizzbuzz('')
console.log(output);</script>
//Challenge 6: FIZZBUZZ
//Write a program that prints all of the numbers from 1 to 11 in multiples of 3,
//instead of the number, print "fizz", for multiples of 5 print "buzz", for numbers
//Which are mutiples ofboth 3 and 5, print "Fizzbuzz".
function fizzbuzz()
{
//Loops through 1 - 100
for(let i = 1; i <= 100; i++)
{
if(i % 3 === 0 && i % 5 === 0)
{
console.log('FizzBuzz')
}
//If there is a remainder of 3
else if(i % 3 === 0) {
console.log('Fizz')
} else if(i % 5 === 0)
{
console.log('FizzBuzz')
}
else
{
console.log(i);
}
}
}
const output = fizzbuzz('')
console.log(output);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment