Created
February 26, 2017 17:31
-
-
Save giltayar/cdc25788c6c245bb8b812215879a2423 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports.initialState = { display: '0', initial: true } | |
module.exports.nextState = (calculatorState, character) => { | |
if (isDigit(character)) { | |
return addDigit(calculatorState, character) | |
} else if (isOperator(character)) { | |
return addOperator(calculatorState, character) | |
} else if (isEqualSign(character)) { | |
return compute(calculatorState) | |
} else { | |
return calculatorState | |
} | |
} | |
//.... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment