The Code
Entry Point - getValues()
Check for all FizzBuzz - generateFizzBuzz()
Display results as a table- displayFizzBuzz()
Logic for this app:
getValues()
generateFizzBuzz()
displayFizzBuzz
Bonus:
Error Messages:sweetAlerts
Entry Point - getValues()
The getValues
function is the entry point function that calls all the other functions
and adds them to the stack. It also handles validating the inputs before passing them as inputs into
the other functions. If the inputs are not valid a Sweet Alert error will display on the UI
informing the app user of the failure along with a short description of the exact problem.
Check for all FizzBuzz - generateFizzBuzz()
The generateFizzBuzz
function takes the parameters from getValues
after
the have been checked for validation and will then loop through all the numbers starting at 1 and
continue until it reaches the end number the user has chosen. It will then check if the current
number in the index is a valid Fizz, Buzz, or FizzBuzz number and add it to a new array. This new
array will have the integers and strings we need to build a table that can display the results to
the UI. generateFizzBuzz
will then return the new array to getValues
and
that array will be passed to displayFizzBuzz
.
Display results as a table- displayFizzBuzz()
The displayFizzBuzz
function takes the array from getValues
after the
generateFizzBuzz
function has created the array with the expected output and will turn
that array into a table for the user to see on the UI. It will display by changing the HTML on the
page effectively inserting the table directly into the HTML.