Skip to content

HelcioAnicio/calculator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 

Repository files navigation

Calculator

This website is a calculator, here you will be able to add, subtract, multiply and divide the math you need to do.

Table of contents

Overview

The challenge

The users should be able to:

  • Add, subtract, multiply and divide the math.
  • See the display with numbers clicked.
  • View the optimal layout depending on their device's screen size.

Screenshot

  • image

Links

My process

Built with

  • Semantic HTML5
  • Flexbox
  • JavaScript
  • Conditional
  • Object orientation
  • Metods
  • Classes
  • Events
  • Ternary conditional

What I learned

How create metods, classes and constructor. For the first time i used object orientation in my projects.

class Calculator {
  constructor(previewDisplayText, actualDisplayText) {
    this.previewDisplayText = previewDisplayText;
    this.actualDisplayText = actualDisplayText;
    this.clear();
  }

  calculate () {
    let result;

    const _previewDisplay = parseFloat(this.previewDisplay);
    const _actualDisplay = parseFloat(this.actualDisplay);

    if (isNaN(_previewDisplay) || isNaN(_actualDisplay)) return;

    switch (this.operator) {
      case "+":
        result = _previewDisplay + _actualDisplay;
        break;

      case "-":
        result = _previewDisplay - _actualDisplay;
        break;

      case "/":
        result = _previewDisplay / _actualDisplay;
        break;

      case "*":
        result = _previewDisplay * _actualDisplay;
        break;

      default:
        break;
    }

Continued development

I will developer my projets using OOP to better knowledge and practice.

Useful resources

This resource helped me a lot to understand how to do to implemented JS. https://www.w3schools.com/ https://developer.mozilla.org/en-US/ https://stackoverflow.com/

Author

About

This is a calculator website.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published