Skip to content

Instantly share code, notes, and snippets.

@giltayar
Created February 26, 2017 17:31
Show Gist options
  • Save giltayar/cdc25788c6c245bb8b812215879a2423 to your computer and use it in GitHub Desktop.
Save giltayar/cdc25788c6c245bb8b812215879a2423 to your computer and use it in GitHub Desktop.
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