# Build a JavaScript Calculator doubt

**URL:** <https://forum.freecodecamp.org/t/build-a-javascript-calculator-doubt/208547>\
**Category:** I Built This\
**Created:** [July 13, 2018, 5:29pm UTC](https://forum.freecodecamp.org/t/build-a-javascript-calculator-doubt/208547 "2018-07-13T17:29:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![midhunlc](https://avatars.discourse-cdn.com/v4/letter/m/47e85d/32.png) [@midhunlc](https://forum.freecodecamp.org/u/midhunlc)\
**Post date:** [July 13, 2018, 5:29pm UTC](https://forum.freecodecamp.org/t/build-a-javascript-calculator-doubt/208547/1 "2018-07-13T17:29:59Z")

</div>

I have finished the calculator project using React.  
i used built in javascript method eval() for calculating the expression values entered in the calculator after modifying them according to project requirements.  
My question is,is there a better way of doing it?I read online that eval is not safe and is pretty resource consuming.  
Ofcourse i can parse the input and write the logic myself but are there any javascript alternatives?.

> **[qyOdxb](https://codepen.io/MidhunLC/pen/qyOdxb)**
>
> ...

---

<div class="post-metadata">

**Author:** ![midhunlc](https://avatars.discourse-cdn.com/v4/letter/m/47e85d/32.png) [@midhunlc](https://forum.freecodecamp.org/u/midhunlc)\
**Post date:** [July 13, 2018, 6:10pm UTC](https://forum.freecodecamp.org/t/build-a-javascript-calculator-doubt/208547/3 "2018-07-13T18:10:24Z")

</div>

hey,  
thanks for the feedback.  
I am not calculating for expressions with no digits before the decimal point.I have fixed that.  
More importantly I was asking about alternative ways than using java eval.

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [January 17, 2021, 7:48pm UTC](https://forum.freecodecamp.org/t/build-a-javascript-calculator-doubt/208547/4 "2021-01-17T19:48:05Z")

</div>

Closed on January 17, 2021, 7:48pm UTC


