Advertisement
Guest User

FozzBzazz

a guest
Dec 16th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Console the numbers from 1 to 100
  2. for ( var num = 1; num < 101; num ++ ) {
  3.  
  4.   // check if the number is multiples of 3 or 5
  5.   var checkForThree = num % 3;
  6.   var checkForFive = num % 5;
  7.  
  8.   // if the number is multiples of both 3 and 5, then print FozzBzazz
  9.   if ( (checkForThree == 0) && (checkForFive == 0) )
  10.     console.log( "FozzBzazz");
  11.  
  12.   // if the number is multiples of 3, then print Fozz
  13.   else if (checkForThree == 0)
  14.     console.log( "Fozz");
  15.  
  16.   // if the number is multiples of 5, then print Bzazz
  17.   else if (checkForFive == 0)
  18.     console.log( "Bzazz");
  19.  
  20.   // otherwise just print the number
  21.   else
  22.     console.log( num );
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement