Todo list:
- code refactor
- After click CE, cannot change operator.
- bug unsolved decimal calculations 0.2 + 0.1 = 0.30000000000000004
- Build html page.
- Add event listener. Print button innerHTML when clicked.
- Using
.bind
to on hold callback function.
- Mind map:
- Add
printNum
andprintOperator
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.
- Add
calcResults
to handle the expression array and print result.
- 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.
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.
- 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