From d47c1ea379167c8b4376c1241ff3799c8ce983fb Mon Sep 17 00:00:00 2001 From: afterthebleep Date: Thu, 23 Mar 2017 14:10:24 -0700 Subject: [PATCH] completed fizzBuzz exercise. all test passing --- src/fizzBuzz.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 src/fizzBuzz.js diff --git a/src/fizzBuzz.js b/src/fizzBuzz.js new file mode 100644 index 0000000..0e820cb --- /dev/null +++ b/src/fizzBuzz.js @@ -0,0 +1,14 @@ +let list = new Array(100); + + for (let i = 0; i < 100; i++) { + list[i] = i + 1; // $$c populates the array. +1 is necessary because arrays are 0 index based and you want to store 1 - 100 in it, NOT 0-99.{ + + //list[i] is equal to an index in the array + if (list[i] % 5 === 0 && list[i] % 3 === 0) { // populate multiples of both five && three with "FIZZBUZZ" + list[i] = "FizzBuzz" + } else if (list[i] % 5 === 0) { // populate multiples of five with "BUZZ" + list[i] = "Buzz" + } else if (list[i] % 3 === 0) { // populate multiples of three with "FIZZ" + list[i] = "Fizz" + } + }