React Calculator : feedback

Hi @houc.bh90,

  • General comments:

    • Why did you use classes and not functions? I’m not saying that is wrong. There is a reason to not use functions?

    • Your project has no comments, and because of that is really difficult to grasp the “shape” of your solution.


  • Inputs

  • Your project at the moment can’t parse (handle) this input:

0.000


I tried determine why, but I had some limitations:

  • I don’t know how to debug code in codepen
  • I couldn’t determine the state of the program (because I didn’t executed the code)
  • Because of the lack of comments I had to assume some elements of the program (“.” is a number, a string or a special type()?)

So, this is more or less a guess:

input: 0.00

line 47 zero, 0, typeof number? (There is no comment about this)

state input next side effects
initial? number handleNums 0 (line 113)

line 46 decimal, “.”, typeof ?? (There is no comment about this), line 79

state input next side effects
? “.” handleDecimal 0. (line 167)

line 47 zero, 0, typeof number? (There is no comment about this)

state input next side effects
? number handleNums .0 (line 113)

line 47 zero, 0, typeof number? (There is no comment about this)

state input next side effects
? number handleNums .0 (line 113)

Why (replace) ?

    crntN: this.state.crntN.replace('0','') + i,

This is a video of the process:

Cheers and happy coding :slight_smile:

1 Like