barberboy / fizzbuzz

An exercise using variables, operators, strings, numbers, and loops.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

FizzBuzz

Join the chat at https://gitter.im/unioncollege-webtech/fizzbuzz

An exercise using variables, operators, strings, numbers, and loops.

Description

Create a file called “fizzbuzz.js”, which logs the numbers from 1 to 100 to the console, but for multiples of three (3), log the word “Fizz” instead of the number, and for multiples of five (5) log “Buzz”, and for numbers which are multiples of both three and five, log “FizzBuzz”.

For instance, the first twenty lines of output from the program would look like this:

1
2
Fizz
4
Buzz
Fizz
7
8
Fizz
Buzz
11
Fizz
13
14
FizzBuzz
16
17
Fizz
19
Buzz
...

Run node fizzbuzz.js and review its output to ensure it is functioning correctly.

Testing

If you want to test your code as you are going along, you can run this command:

node test

Hints

See References for links to operators and language features that will be helpful in completing this assignment.

Extra Credit

Define a function called fizzbuzz which accepts a single argument, max, and logs the appropriate output up to that number. For instance, calling fizzbuzz(5); would log the following:

1
2
Fizz
4
Buzz

Call fizzbuzz for the numbers 5, 13, 89, and 233.

Completing and submitting the assignment

You are also welcome commit, push, and create a pull request before you’ve completed your solution. You can ask questions or request feedback there in your pull request. Just mention @barberboy in your comments to get my attention.

References

About

An exercise using variables, operators, strings, numbers, and loops.

License:ISC License


Languages

Language:JavaScript 100.0%