JavaScript Calculator - FreeCodeCamp

JavaScript Calculator - FreeCodeCamp
0.0 0

#1

Hello guys!

I just finished my Javascript Calculator, it’s available in the next link: https://codepen.io/techednelson/full/gxorJr/

I would appreciate any feedback!

Thanks & regards,

Nelson


#2

your calculator looks great.
how do i perform an operation like:
-2 x -2
I am having trouble entering the minus/negative number after the first operator.


#3

Hello psyperl,

Thanks for your feedback, I have fix the issue. You can click +/- 2, then x, 2 again & finally +/- to have -2x-2 = 4.

if you find further bugs, I would appreciate your help.

Regards,

Nelson


#4

Hi Nelson,

It looks really nice but one problem I see which happens with a lot of people is that your calculator fails to honor order of operations. (Please Excuse My Dear Aunt Sally if you remember from school.) For instance 3+5*6 should give you 33 i.e. 3 + (5 * 6) but yours gives 48 i.e. (3 + 5) * 6.


#5

Hi Jaldhar!

Thanks for your feedback! I understand your point. A scientific calculator normally would have more options like exponential, logarithms, parenthesis, etc & would take care of the order of operators. However, for the fcc challenge, a Basic format was the paremeter to follow, when I created the calculator I did it following the FreeCodeCamp example & a basic calculator like the calculator in a Mac in its basic format. It would be interesting though, to code a scientific calculator for practice purposes. Thank you once more for taking your time to test & comment about my projects.

Kind Regards!


#6

Even a cheap $5 Walmart desk calculator should be able to handle order of operations. That’s pretty essential IMO.

And it’s easy to take care of. Hint: don’t do the math yourself but rely on JavaScripts eval function to do it for you.


#7

Thanks a lot Jaldhar, I follow your advise, so I have recode the calculator, it took me a little long due to summer holidays, I took a rest, however, it was great & I learnt a lot, recreating the code. you can check the result.

Thanks once more!

if you fine a mistake, please feedback as always is more than welcome.

Kind Regards,

Nelson