Skip to content
Advertisement

Javascript returning SUM 0

Sorry for this basic JS question.

I have this code:

JavaScript

my value is always 0.

I know it’s because let is not changing, but I don’t know why.

Could you help me, please?

Advertisement

Answer

parseInt('0.3') is 0. So one of your values is 0, so the result will always be 0. Try using parseFloat instead.

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement