Adding numbers together from a number field isn't working

I'm trying to use a create a basic earnings calculator and I'm having a problem where it doesn't add up both numbers typed in, to calculate the sum. Instead it just combines the two numbers together by putting them on the end.

I chose a number field for my form instead of a text (string) field, so it should be adding up to make the sum.

Strangely enough, it works when I try to make a desktop app but not for a mobile app.

Is this a bug or am I doing something wrong?

Apparently number input value outputs a string (not a number) so "+" will just concatenate 2 strings.

This definitely sounds like a bug @Tess :wave:

just wrap them in parseInt("1") + parseInt("2") and it should work properly.

Could work if the values are not decimal (thus why worth avoiding .parseInt), if they are they will be rounded so not going to work.

However you can use parseFloat to workaround this while this gets fixed as in example:

Lurking here! This is indeed a bug, but since the component was released with this functionality, fixing it would be backwards incompatible unless we release an entirely new number input component (which we may do, so I'll keep this thread updated!)

{{ Number(numberInput1.value) + Number(numberInput2.value) }} worked for me;
Please make sure N is in capital for 'Number'.

Also, did a {{ (Number(numberInput1.value) + Number(numberInput2.value) ).toFixed(2) }} to round the value

1 Like

Thanks so much for sharing