+ 4
Javascript calculator not working
Here is my simple calculator app. https://code.sololearn.com/WWCMUbpjJSY1/?ref=app It is showing the answer but completely different from javascript eval calculator
4 RĂ©ponses
+ 5
Sarthak đłđ” sorry, it must be my machine/device. It sometimes doesnât work with the latest features.
+ 4
With your code as is any operator and operand after the grouping is being removed from the equation before it is calculated.
[30] - [30] * [2] /( [4] - [8] )/ [2] * [7]
= [30] - [30] * [2] / [-4] * [7]
= [30] - [30] * [-0.5] * [7]
= [30] - [-15] * [7]
= [30] - [-105]
= [135]
:. Answer = [135]
Answer By Eval: 82.5
In this case '/2' is removed before being calculated as a part of the equation.
This only seems happens when there is a grouping/parens.
I suggest moving 'soln.splice(index,2);' to the codeblock of the 'if(!nestProc)'
+ 3
Sorry, but we canât see the output since we donât have the other JavaScript files.
+ 2
Rowsej
I've bundled all JavaScript files into one file. And I receive an output.