Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Console the numbers from 1 to 100
- for ( var num = 1; num < 101; num ++ ) {
- // check if the number is multiples of 3 or 5
- var checkForThree = num % 3;
- var checkForFive = num % 5;
- // if the number is multiples of both 3 and 5, then print FozzBzazz
- if ( (checkForThree == 0) && (checkForFive == 0) )
- console.log( "FozzBzazz");
- // if the number is multiples of 3, then print Fozz
- else if (checkForThree == 0)
- console.log( "Fozz");
- // if the number is multiples of 5, then print Bzazz
- else if (checkForFive == 0)
- console.log( "Bzazz");
- // otherwise just print the number
- else
- console.log( num );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement