Skip to content

wardcj1/Calculator-Basic

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Calculator-Basic

A calculator with basic operations powered by jQuery

ScreenShot

Live Link

Sample Code

    $(".operator").on("click", function() {
        if (isCalculated) return;
        isOperatorChosen = true;
        operator = this.value;
        $("#operator").html($(this).text());
    });

    $(".equal").on("click", function() {
        if (isCalculated) return;
        isCalculated = true;
        firstNumber = parseInt(firstNumber);
        secondNumber = parseInt(secondNumber);
        if (operator === "plus") {
          result = firstNumber + secondNumber;
        }
        if (operator === "minus") {
          result = firstNumber - secondNumber;
        }
        if (operator === "times") {
          result = firstNumber * secondNumber;
        }
        if (operator === "divide") {
          result = firstNumber / secondNumber;
        }
        if (operator === "power") {
          result = Math.pow(firstNumber, secondNumber);
        }
        $("#result").html(result);
    });

About

Calculator with basic operations

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published