/calculator

basic calculator for theodinproject curriculum

Primary LanguageJavaScript

Calculator

Introduction

This project is a simple design of a calculator that can operate two numbers at a time. It supports positive/negative and floating numbers.

Goals and Objectives

  • Create a basic calculator with buttons for each digit, functions, clear, and equal key
  • Once the keys are clicked, the corresponding numbers will be shown at display
  • Add keyboard support
  • Allow decimal and negative numbers
  • Add backspace button

How it works

  • There is no display within the screen when the user enters the site

  • To enter numbers, the corresponding buttons should be clicked/pressed

    Number/Function Key
    One 1
    Two 2
    Three 3
    Four 4
    Five 5
    Six 6
    Seven 7
    Eight 8
    Nine 9
    Zero 0
    Add +
    Subtract -
    Multiply *
    Divide % or /
    Erase Backspace
    Clear All C or c
    Positive/Negative Spacebar
    Decimal Point .
  • To operate two numbers, the equal button must be clicked/pressed to get the answer.

  • Previous answer can be used as operand for the next operation

Skills Emphasized in this Project

  • DOM Manipulation
  • Click and keydown event listeners
  • Function scope
  • Connecting keys to DOM Elements
  • Selecting DOM Elements
  • Conditional statements
  • String methods
  • Grid Design
  • Event properties

Thoughts After Completion

This project was confusing for me because there are a lot of bugs to watch out for. While trying to fix the bugs, I tried to challenge myself by finding the most efficient solutions I can think of. The solutions I have now may not be the best yet but I'll definitely fix it when I become better in the future. Overall, This project was kinda tough but I am satisfied with my finished work.