GithubHelp home page GithubHelp logo

js-calculator's Introduction

js-calculator

Todo list:

  • code refactor
  • After click CE, cannot change operator.
  • bug unsolved decimal calculations 0.2 + 0.1 = 0.30000000000000004

20 Feb

  • Build html page.

21 Feb

  • Add event listener. Print button innerHTML when clicked.
  • Using .bind to on hold callback function.

22 Feb

  • Mind map:

Image of Prototype_chain

  • Add printNum and printOperator function.
  • Find a way to convert expression string into array
11+11*11/11 => [11, +, 11, *, 11, /, 11] 
  • Add highPriorityOperatorIndex to check the index of first * or / if have.

23 Feb

  • Add calcResults to handle the expression array and print result.

24 Feb

  • Print the expression and result on page by click buttons.
  • Add function to handle AC button.
  • Fix bug when convert expression string to array.
  • Add function if click number after click enter refresh the expression print.

25 Feb

New IDEA

    expressionStr = "";
    lastChar = expressionStr[expressionStr.length - 1];
    expressionArr = [];
- When click Num:
    check if it's dot. 
    expressionStr += num;
    lastChar = expressionStr[expressionStr.length - 1];

- When click operator:
    check if lastChar match operator 
        if not, push str into expressionArr. 
                push operator into expressionArr.
                empty expressionStr.
                lastChar = operator

It works! But code is ugly! need refactor.

26 Feb

  • Add CE function
  • Add keyboard num and operators input function
  • Add minus button in html
  • Add negative calc function
  • Add function. When click operator after an operator, change to the current one.
  • fix a bug when handle CE

js-calculator's People

Contributors

frankxuzy avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.