JSFiddle - React, Tailwind, and code Playground

by Brain Baghdasarov

JavaScript

//1. For numbers from 1 to 100:
//
// Print that number
// If number divides from 3, print Fizz instead
// If number divides from 5, print Buzz instead
// If number divides from both 3 and 5, print FizzBuzz instead
// Expected output:
//
//   1 2 Fizz 4 Buzz Fizz 7 8 Fizz Buzz 11 Fizz 13 14 FizzBuzz 16 ... 98 Fizz Buzz


//2. Bar Baz
// Maintain the code from task v1, it's still used in the system.
//
// For numbers from 1 to 100:
//
// Print that number
// If number divides from 7, print Bar instead
// If number divides from 11, print Baz instead
// If number divides from both 7 and 11, print BarBaz instead
// Expected output:
//
//   1 2 3 4 5 6 Bar 8 9 10 Baz 12 13 Bar 15 ... 76 BarBaz 78 ... Bar Baz 100
// As task v1 should be mainained, full expected output would be something like this:
//
// Fizz Buzz:
//   1 2 Fizz 4 Buzz Fizz 7 8 Fizz Buzz 11 Fizz 13 14 FizzBuzz 16 ... 98 Fizz Buzz
//
// Bar Baz:
//   1 2 3 4 5 6 Bar 8 9 10 Baz 12 13 Bar 15 ... 76 BarBaz 78 ... Bar Baz 100
// It would be really great if there would be no copy-and-paste.

// 3. Maintain the code from task v1 and v2, as it's still used in the system. For numbers from 1 to 100:
//
// Print that number
// If number is between 3 and 6, print Fizz instead
// If number is ends with 5, print Buzz instead
// If both conditions are true, print FizzBuzz instead
// Expected output:
//
// 1 2 Fizz Fizz FizzBuzz Fizz 7 8 9 10 11 12 13 14 Buzz 16 ... 100
// As task v1 and v2 should be mainained, full expected output would be something like this:
//
// Fizz Buzz:
// 1 2 Fizz 4 Buzz Fizz 7 8 Fizz Buzz 11 Fizz 13 14 FizzBuzz 16 ... 98 Fizz Buzz
//
// Bar Baz:
// 1 2 3 4 5 6 Bar 8 9 10 Baz 12 13 Bar 15 ... 76 BarBaz 78 ... Bar Baz 100
//
// Fizz Buzz with different logic:
// 1 2 Fizz Fizz FizzBuzz Fizz 7 8 9 10 11 12 13 14 Buzz 16 ... 100
// It would be really great if there would be no copy-and-paste.
//
// Parameters and logic can be changed or added - it's best if your code would be easily maintanable,...