Advertisement
AuriR

Beginning Programming - Fizz Buzz with Array

Mar 1st, 2015
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var theArray = [];
  2. for (var n = 1; n <= 100; n++) {
  3.   if (n % 15 == 0) {
  4.      theArray[theArray.length] = "FizzBuzz";
  5.   }
  6.   else if (n % 5 == 0) {
  7.      theArray[theArray.length] = "Buzz";
  8.   }
  9.   else if (n % 3 == 0) {
  10.      theArray[theArray.length] = "Fizz";
  11.   }
  12.   else {
  13.      theArray[theArray.length] = n;
  14.   }
  15. }
  16.  
  17. for(theEntry: theArray)
  18. {
  19.   print(theEntry);
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement