The project is centered on the design and implementation of a simple calculator for educational purpose.
The simple calculator project is focused on numbers and arithmetics operations. The end result of the calculator is to provide a correct result of mathematical operation.
Project is created with:
- HTML5
- CSS3
- JS ES6
Project is: in progress
function oper(value) {
var result = document.getElementById("result");
if (result.value.length !== 0) {
var lastChar = result.value.slice(result.value.length-1);
var regularExpression = /[0-9]/;
var re = /^(\+|-|\*|\/|=|>|<|>=|<=|&|\||%|!|\^|\(|\))$/;
if (lastChar.match(regularExpression) !== null) {
result.value += value;
}
else if (lastChar.match(re) !== null) {
result.value = result.value.slice(0, -1) + value;
}
}
}
- Mathematical operations are working as expected
- Results of operations are correct (with the use of mathematical order of operations)
- Operators cannot be entered more than once if the last character is not a number
- if the user changes his or her mind and decide to change the operator, the calculator will replace the last character (for example from "+" to "-")
- Decimal point or operators cannot be enterd if the result field is empty
- Decimal point can be only provided once in one string
- Evaluation after every operation (block mathematical order of operations)
Contributions to the project library are welcome. Please note the following guidelines before submitting your pull request:
- Follow JS coding standards
- Write tests for new functions and added featues
MIT License: Copyright (c) 2018 Martyna Zyskowska
Martyna Zyskowska