Skip to content

Instantly share code, notes, and snippets.

@krcrawford
Created March 6, 2019 21:28
Show Gist options
  • Save krcrawford/0d6a3710e2c01d95aa55186616a77497 to your computer and use it in GitHub Desktop.
Save krcrawford/0d6a3710e2c01d95aa55186616a77497 to your computer and use it in GitHub Desktop.
Javascript Homework #6
const fizzbuzz = () => {
let index = 0, max = 100, log = '';
const initialPrimes = [2, 3, 5, 7, 11];
for (; index < max; index++) {
if ((index !== 1 && initialPrimes.indexOf(index) !== -1) ||
(index !== 1 &&
index % 2 !== 0 &&
index % 3 !== 0 &&
index % 5 !== 0 &&
index % 7 !== 0)) {
log = "prime";
} else if (index % 3 === 0 && index % 5 === 0) {
log = "FizzBuzz";
} else if (index % 3 === 0) {
log = "Fizz";
} else if (index % 5 === 0) {
log = "Buzz";
} else {
log = index;
}
console.log(log);
}
}
fizzbuzz();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment