Created
February 29, 2016 11:22
-
-
Save nire0510/8b424b019ac40dd93712 to your computer and use it in GitHub Desktop.
Ember helper: performs arithmetic operations
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
import Ember from 'ember'; | |
export function math([numOperand1, strOperator, numOperand2]/*, hash*/) { | |
numOperand1 = parseFloat(numOperand1); | |
numOperand2 = parseFloat(numOperand2); | |
return { | |
'+': numOperand1 + numOperand2, | |
'-': numOperand1 - numOperand2, | |
'*': numOperand1 * numOperand2, | |
'/': numOperand1 / numOperand2, | |
'%': numOperand1 % numOperand2, | |
'^': numOperand1 ^ numOperand2 | |
}[strOperator]; | |
} | |
export default Ember.Helper.helper(math); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment