Created
October 16, 2021 09:00
-
-
Save WesleySmits/b9cada08d6a744e1fc45438d2c3f19cb to your computer and use it in GitHub Desktop.
Simple web calculator: Perform calculation
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
#performCalculation(): void { | |
const displayQuery = this.query.replace('÷', '/').replace('x', '*'); | |
const answer: number = eval(displayQuery); | |
const formattedAnswer = +parseFloat(answer.toString()).toFixed(2); | |
this.query = formattedAnswer.toString(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment