Skip to content

LukyLurks/calculator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Calculator

A calculator made as part of The Odin Project's web development 101 course.

Screenshot of the calculator

Usage

Structure

The project follows the structure explained in this MDN article.

  • scripts/main.js: the script, essentially in 2 parts.

    • input: each newly inputted digit/dot/parenthese/operator is checked against the rest of the inputted expression by updateExpr(), in order to prevent invalid things like several operators in a row, excessive closing parentheses, multiple dots in a single number, etc.
    • calculations: the inputted expression is parsed as a string and PEMDAS is repeatedly applied until we get a number with calculateExpression()

    Almost everything else is regexes or functions to deal with all the cases, so looking at those 2 functions first is a good way to grasp the code.

  • styles: Eric Mayer's CSS reset and my own CSS

  • index.html: all the HTML code

License

This project is licensed under the MIT license.

Releases

No releases published

Packages

No packages published