Giter VIP home page Giter VIP logo

browser-calculator's Introduction

browser-calculator

This is a very simple calculator web app I built using HTML, CSS, & vanilla JavaScript. Here are its features:

  • A different background image randomly from an array of image URLs, displays

  • The value (text content of each button that is clicked) is pushed into an array, which is later joined so that the eval() method can be used to calculate the operation & the result can be displayed. I know using the eval() method is not the best thing to do when handling sensitive information, but this is only meant to be a simple calculator.

  • Error-handling:

    • To check if the first or last thing the user inputs is a mathematical operator, I loop through an array containing these symbols. If the first or last item input is one of these things, an "Invalid operation" error message displays. This message also displays if there is some other kind of syntax error.
    • If two consecutive operators are added, the first one is deleted & the second one displays & is used in the calculation.
    • To ensure the amount of input characters doesn't exceed the width of the 'screen' area of the calculator, the user can see a message informing the user of the character limit, although the operation can still be done.
    • If the user tries to divide by zero, the "Invalid operation" displays.
  • When the user clicks the 'clear' button, all previous input is erased & the calculator 'screen' displays the default '.'.

  • When the user clicks the 'equals' button, & the operation is valid, the result displays on the calculator screen & previous input is erased so a new operation can be done.

  • If the result of the operation is an integer, the whole number displays. Otherwise, the decimal is rounded to two places.

  • The page is also mobile-responsive.

browser-calculator's People

Contributors

egroene avatar

Watchers

 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.