Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added an additional condition and added a recursive example. #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 27 additions & 17 deletions problem.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,30 @@
function fizzBuzz(){
//This must print 1-100 in the console
//If divisible by 3, print fizz
//If divisible by 5, print buzz
//If divisible by 3 and 5, print fizzbuzz
//Else, print the number
for(i=1;i<=100;i++){
if(i % 3 === 0){
console.log("fizz");
}
else if(i % 5 === 0){
console.log("buzz");
}
else{
console.log(i);
}
function fizzBuzz() {
// This must print 1-100 in the console
// If divisible by 3, print fizz
// If divisible by 5, print buzz
// If divisible by 3 and 5, print fizzbuzz
// Else, print the number
const { log } = console;
for (let i = 1; i <= 100; i++) {
if (i % 3 === 0 && i % 5 === 0) log("fizzbuzz");
else if (i % 3 === 0) log("fizz");
else if (i % 5 === 0) log("buzz");
else log(i);
}
}
fizzBuzz();

fizzBuzz();
// Recursively...
/*
function eval(int = 0) {
if (int > 100) return;

if (int % 3 === 0 && int % 5 === 0) console.log("fizzbuzz");
else if (int % 3 === 0) console.log("fizz");
else if (int % 5 === 0) console.log("buzz");
else console.log(int);

eval(int + 1);
}
eval();
*/