+ 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

30th Apr 2020, 7:24 AM
Sarthak
Sarthak - avatar
4 Respuestas
+ 5
Sarthak 🇳🇵 sorry, it must be my machine/device. It sometimes doesn’t work with the latest features.
1st May 2020, 7:48 AM
Rowsej
Rowsej - avatar
+ 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)'
2nd May 2020, 3:39 PM
ODLNT
ODLNT - avatar
+ 3
Sorry, but we can’t see the output since we don’t have the other JavaScript files.
30th Apr 2020, 9:13 AM
Rowsej
Rowsej - avatar
+ 2
Rowsej I've bundled all JavaScript files into one file. And I receive an output.
30th Apr 2020, 12:29 PM
Sarthak
Sarthak - avatar