Giter VIP home page Giter VIP logo

wats1020-fizzbuzz's Introduction

wats1020-fizzbuzz

This is the first Javascript coding assignment for WATS1020: Introduction to Javascript at Seattle University. The goal of this project is to illustrate an understanding of the basic concepts of Javascript, including variable assignment, loops, and conditionals.

This assignment takes inspiration from the old interview challenge known as "Fizzbuzz". This is a common coding challenge to see presented in job interviews, and there are many ways to solve it in every language. We are not aiming to create the most sophisticated, obscure or tiny implementation. We aim to create a clear, understandable logic that builds on the basic components of Javascript.

Requirements

Fizzbuzz originates as a children's game to teach them about division. The rules of the game are thus:

  1. Players stand in a circle and count off in sequence beginning with the number "1".
  2. For each player, when it is their turn to count off, they must first decide if the number they have come to is divisble by 3, 5, or both.
    • If the number is divisible by 3, the player says, "Fizz."
    • If the number is divisible by 5, the player says, "Buzz."
    • If the number is divisible by both 3 and 5, the player says, "FizzBuzz."
    • If none of these conditions are true, the player says the number.

In the children's game, if a child gets one wrong, they must sit down, and the last child standing wins.

We will use a slightly modified verison of the play. Our goal is to create a script that will run through the numbers 1-20 and highlight all of the "Fizz", "Buzz", and "FizzBuzz" digits in that sequence. Here are the base requirements for your script:

  • Write a script to execute the FizzBuzz rules in the file fizzbuzz.js and determine the first 20 correct responses.
  • Log all output to the console using console.log() statements.
  • Iterate using a for loop through the sequence of numbers 1-20.
  • For each number, check these conditions and respond appropriately:
    • If the number is divisible by 3, print "Fizz" to the console.
    • If the number is divisible by 5, print "Buzz" to the console.
    • If the number is divisible by BOTH 3 and 5, print "FizzBuzz" to the console.
    • If none of these conditions are met, print the number to the console.
  • Use proper variable scope and type definitions where appropriate.
  • Use proper variable naming styles (camelCase) and comment your code to indicate functionality in plain (non-jargon) language.

Here is an example output that shows what any successful solution is going to give as a result:

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

I will run your script in a standard Javascript console with no additional libraries installed to evaluate your success. I expect to see a result identical to the one provided above.

If you wish to pursue stretch requirements you can explore how you might accomplish the following:

  • Output the results of your script directly into the web page.
  • Encapsulate your FizzBuzz logic into a Function.

Tips

  • You can write Javascript using the Developer Tools in any modern web browser. You can get tips about using Developer Tools all over. Here's a good place to start: https://developer.chrome.com/devtools/docs/authoring-development-workflow
  • There are a lot of tutorials and discussions of FizzBuzz online, and you are welcome to consult them. But please be aware that you may be spoiling the challenge for yourself, and that you may find people writing FizzBuzz in ways that are exotic or obscure.

wats1020-fizzbuzz's People

Contributors

shawnr avatar mattfromseattle avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.