44
loading...
This website collects cookies to deliver better user experience
%
%
) operator.%
) operator so you have to find an alternative way to check if a number should have Fizz, Buzz and or FizzBuzz logged to the console instead.%
.Window.localStorage
to store the current number.localStorage
until the "next" button is pressed for the first time.localStorage
entry entirely.<div>
to display the number using a different function that calls your fizz buzz function. You can overwrite the number or keep a record and display each new number on a new line.<div>
on the page.null
when this happens (e.g. the first output will be (null
, 1, 2) and the last will be (99, 100, null
...see next point though). <table>
with the following format:number | previous value | current value | next value |
---|---|---|---|
! 26 | Buzz | 26 | Fizz |
27 | 26 | Fizz | 28 |
28 | Fizz | 28 | 29 |
29 | 28 | 29 | FizzBuzz |
<input>
s to your example that take the minimum value and the maximum value.<div>
. true
the numbers should start at the maximum and count backwards to the minimum, if set to false
they should return in ascending order the same as before.myFizzBuzzFunction(false)
(which will still write 1 - 100). However myFizzBuzzFunction(true)
will return 100 - 1 (reversed).myFizzBuzzGenerator(smallNo, largeNo)
or with myFizzBuzzGenerator(smallNo, largeNo, false)
, myFizzBuzzGenerator(smallNo, largeNo, true)
etc. myFizzBuzzGenerator(smallNo, largeNo, true)
should be the one that reverse the order. number | direction | previous value | current value | next value |
---|---|---|---|---|
! 26 | forward (or false) | Buzz | 26 | Fizz |
27 | forward (or false) | 26 | Fizz | 28 |
28 | forward (or false) | Fizz | 28 | 29 |
29 | forward (or false) | 28 | 29 | FizzBuzz |
28 | backwards (or true) | Fizz | 28 | 29 |
27 | backwards (or true) | 26 | Fizz | 28 |
let wordsAndDivisors =
[
{"word": "Fizz", "divisor": 3},
{"word": "Buzz", "divisor": 5},
{"word": "Fluff", "divisor": 7}
]
////your function should log
1
2
"Fizz"
4
"Buzz"
"Fizz"
"Fluff"
8
"Fizz"
"Buzz"
11
"Fizz"
13
"Fluff"
"FizzBuzz"
[...]
92
"Fizz"
94
"Buzz"
"Fizz"
97
"Fluff"
"Fizz"
"Buzz"
const wordsAndDivisors =
[
{"word": "Fizz", "divisor": 3},
{"word": "Buzz", "divisor": 5},
{"word": "Fluff", "divisor": 11}
]
myFunction(wordsAndDivisors);
// 3 = Fizz, 5 = Buzz, 11 = Fluff, 33 = FizzFluff, 55 = BuzzFluff.
const wordsAndDivisorsTwo =
[
{"word": "Fizz", "divisor": 3},
{"word": "Buzz", "divisor": 5},
{"word": "Fluff", "divisor": 7},
{"word": "Biff", "divisor": 11},
{"word": "Buffer", "divisor": 17},
{"word": "Tink", "divisor": 23}
]
myFunction(wordsAndDivisorsTwo);
// 17 = Buffer, 46 = Tink, 77 = FluffBiff, 85 = BuzzBuffer.
myGeneratorFunction(min, max, directionOptional, wordsAndDivisorsOptional)
myGeneratorFunction(1,100)
would just return the numbers 1 to 100myGeneratorFunction(1,100, true)
would return the numbers 100 to 1myGeneratorFunction(1,100, false, wordsAndDivisors)
would return 1 to 100 with fizz, buzz and fluff replacements!myFizzBuzzGenerator()
and it do normal FizzBuzz in a forward direction for the numbers 1 to 100. (Note that this is different behaviour to the non extra credit version). myFizzBuzzGenerator(myGeneratorSettings)
and the min number, the max number, direction etc. all override the defaults if they are passed in!%
) operator!{% jsfiddle <url of fiddle> result js html %}
{% codepen <url of pen> default-tab=result, js, html %}