/calculator

Mobile-friendly vanilla JS calculator

Primary LanguageJavaScript

Calculator

Live demo

Summary

This is a simple calculator built in vanilla JavaScript. Done as part of The Odin Project foundations curriculum.

Features

  • Maths

    • Handles integers and decimals
    • Handles addition, subtraction, multiplication, and division
    • Prevents user from dividing by 0
    • Large answers are given in scientific notation
    • Answers are rounded to be as precise as possible while fitting in the display
  • User experience

    • Responsive layout adjusts to screen height
    • Accepts clicks, keyboard input, and touchscreen input
    • User can string together several operations, with each pair of numbers being evaluated at a time
    • "C" button clears all, "⌫" backspace button deletes most recent digit or character
    • Last equation is displayed in user interface
  • Font

I learned about...

  • Manipulating objects, numbers, and strings
  • Responsive & mobile-friendly design
  • Testing cross-browser compatibility
  • Touchscreen events
  • Importing font families