0 is causing calculation problem
I made this calculator and everything works fine but If I put 0 infront and then perform a calculation then it returns error which I cant figure out why
Github: https://github.com/Pulkit-s21/calculatorThemes.git
Live Site: https://calculator-themes-06ca1e.netlify.app/
GitHub
GitHub - Pulkit-s21/calculatorThemes
Contribute to Pulkit-s21/calculatorThemes development by creating an account on GitHub.
6 Replies
It's probably because the value of
display.value
is not something that eval
is expecting
Try to console log what is display.value
before putting it in eval
function
Maybe you can also try to put the return
keyword right below line 139 in main.js
. I assume that display.value
has value of "Error" or something before it is passed to eval
try and see where what actually is placing the error. you now have an if statement and the catch doing it. put some logs in. Also the return (what Sinc02 suggested) makes sense
its treating the input as octal literal
ah okay, then we'll need to trim of that 0;
place this just before the switch. and use value from then on
I did it but its still giving the same error as before