Skip to content

Instantly share code, notes, and snippets.

@WesleySmits
Created October 16, 2021 09:00
Show Gist options
  • Save WesleySmits/b9cada08d6a744e1fc45438d2c3f19cb to your computer and use it in GitHub Desktop.
Save WesleySmits/b9cada08d6a744e1fc45438d2c3f19cb to your computer and use it in GitHub Desktop.
Simple web calculator: Perform calculation
#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