Giter VIP home page Giter VIP logo

calculator-ts's Introduction

Calculator Exercise

This is a basic calculator build using React, TDD, TypeScript, and styled-components.

Notes regarding building out the calculator:

The calculator was part of a 1 hour and 30 minute exercise, where it wasn't expected for the entire calculator to be built out.

The calculator was built using TDD (Jest and react-testing-library). Unit and integration tests were created, which results in not only the calculator functionality being tested but also what is being displayed on the calculator. react-testing-library issues the calculator commands like a user would, resulting in very robust tests.

There are steps taken to prevent errors, such as repeated operator and equal sign presses, due to this functionality not being added. The codebase allows for this extra functionality to be included in the future.

The calculator uses recursion to work through the equation, allowing it to follow the BODMAS / PEMDAS convention i.e. 10 - 1 * 5 = 5.

There is some functionality missing due to the project being a timed challenge, such as the square root and percentage-of buttons. These can be added at a later stage, however I might rebuild the calculator from scratch and use a state library if there are going to be many more forms of operation.

Installation:

Clone the repo to your computer.

In the root directory of the project, install the dependencies with yarn or yarn install.

Available scripts:

You can run the following scripts from the root directory of the project

yarn start

This will start the development mode of the app and is the easiest way to preview the app.

yarn build

Builds the production in the build folder.

Note regarding serving the app locally:

You can serve this locally by using the serve package, however, it will need to be installed first:

npm install -g serve

serve -s build

You can now open the page at the address given to you, typically http://localhost:5000

yarn test

Runs the Jest test units.

calculator-ts's People

Contributors

martink-rsa 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.