Javascript calculator - decimal duplication

In order to avoid being able to input “9+0.8.1” for example (double decimals)…I added an if statement to my decimal button click function but am getting an error message…I tried both .includes and .indexOf…

Thank you so much for your help!!!

Here’s the code **See line 111

Hi @everythingisnot :wave:

I haven’t looked through the whole logic of your calculator, but the type of userInput after pressing “0” is number (if used on its own or after an operator). includes and indexOf are String methods and therefore don’t exist on number.

I hope that helps :slightly_smiling_face:
Michael

Thank you @mikoMK! This was part of the issue and I think I figured out the rest :slight_smile:

1 Like

I’m glad you figured it out :+1:
Feel free to come back with more questions if you like.

Michael