270: FIBFIZZ  . 
☆ vi hart: fibonacci

FIBFIZZ: Use JavaScript to Dynamically Create FizzBuzz & the Fibonacci Sequence

0. Come to class as there may be corrections, changes and additions.   Significant late penalty per day.
1. Use Notepad++ to create two files.
2. Follow these directions to SUBMIT a folder called "FIBFIZZ" to the D2L dropbox. NOT to be put on the web!!
3. Document! Document the code that is written according to these rules.
4. Review the HONESTY policy. Document sources both inanimate and animate!.
* Some sort of bonus points by using CSS to enhance the interface, not decorate it. *

At startup
ff



After clicking on the FizzBuzz div (both behave the same here)
ff



After entering the number 15 (default) for FizzBuzz
ff



After clicking and entering the number 15 (default) for Fibonacci
ff




YOUR TASK:

Create a folder, "FIBFIZZ"
Create files called ff.html and ff.js
Link the js file appropriately
Generate the numbers for fizzBuzz and use javascript and getElementById() and innerHTML to output in the div dynamically.
Generate the fibonacci numbers into an array and THEN use javascript and getElementById() and innerHTML to output in the div dynamically.

FizzBuzz

A paragraph with a title followed by a description of what will happen when clicked:
  • Create a function called "FizzBuzz" that will be linked to the click event of the appropriate div using "window.onload".
  • Prompt and ask the user for a number, n (max 50, min 1, default 15) - check that it is valid.
  • Generate the numbers 1-n in a loop.
  • If a number is divisible by 3 & 5, output the number and 'FizzBuzz'.
  • If a number is divisible by 3, output the number and 'Fizz'.
  • If a number is divisible by 5, output the number and 'Buzz'.
  • Otherwise simply print the number.
  • Use 'document.getElementById()' and the innerHTML property of the html element with the proper id to output.

Fibonacci

A paragraph with a title followed by a description of what will happen when clicked:
  • Create a function called "Fibonacci" that will be linked to the click event of the appropriate div using "window.onload".
  • Prompt and ask the user for a number, n (max 50, min 1, default 15) - check that it is valid.
  • Compute the first n Fibonacci numbers starting with the pair, 0 and 1, and store the numbers in an array.
  • After filling the array, print the contents of the array so that each number is printed on a line together with a one-up number indicating which Fibonacci number it is.
  • Use 'document.getElementById()' and the innerHTML property of the html element with the proper id to output.
  • Use ".toLocaleString('en')" to include thousand separators

Validating Input:

See the Pen Prompt in a loop by Joseph (@wynottwynott) on CodePen.