Quick JavaScript Solution: FizzBuzz

preview_player
Показать описание
This is a quick guide and solution to the popular FizzBuzz algorithm. Given an array of numbers, loop through that array and if the number is evenly divisible by 3 print “Fizz”, if the number is evenly divisible by 5, print “Buzz”, if this number is divisible by both 3 and 5 print “Fizz Buzz”, and if the number is not divisible by 3 or 5 print the number

Given an array of numbers [12, 13, 14, 15, 16, 17, 18, 19, 20]

Result:
Fizz, 13, 14, Fizz Buzz, 16, 17, Fizz, 19, Buzz
Рекомендации по теме
visit shbcf.ru