Giter Site home page Giter Site logo

js-calculator's Introduction

Js-Calculator

We will be creating calculators by utilizing the Revealing Module Pattern. Scope also comes into play in this exercise as a way to create functions and variables that are either both privately or publically available.

The CalculatorModule will return an object when invoked. This object will have functions attached to it that perform different operations. Users will not be able to access these functions without first creating a new Calculator.

This calculator will also have private variables: total and memory. Users will not be able to access these values directly. Only the functions will be able to interact with those values, functions like: .add(), .subtract(), .multiply(), .divide(), etc.

NOTE: Make sure you VALIDATE all of your inputs!!

"taco" + 3 //Not valid

##Example of useage

var myCalculator = calculatorModule(); // creates a new calculator to be used
myCalculator.load(6); // initial value to be stored in a private variable named `total`
myCalculator.add(5); // adds 5 to `total`
myCalculator.getTotal(); // returns the value of `total`

Getting Started

  1. Fork this repository and clone it from your personal GitHub Account
  2. In the Terminal, navigate to the newly created folder for this repository
  3. Install dependencies by running the command: npm install
  4. Run tests by running the command: npm test
  5. Your work will be one in the file named: calculator.js
  6. Make your tests pass!

References

Front-end Masters' JS fundamentals to functional

Essential Javascript Design Patterns - Module Pattern

js-calculator's People

Contributors

caitypizza avatar sgnl avatar jaywon avatar thgaskell avatar theremix avatar

Watchers

James Cloos avatar  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.