Hi all
Please my observation below when I wanted to test an even number. Is there a limit on the numbers Thunkable can handle.
Youâre testing whether or not a text string is even.
You need to convert the text to a number first. The way to do that is to add zero to the text inputâs text.
Hi Tatiang, Thanks for helping. I changed the settings as above, are they correct? It still gives the same.
No. Those are the exact same blocks.
You need to get the addition (+) block from the Math drawer and add zero (0) to Text_Input3âs Text.
This is a slightly older project but a similar idea:
Another way to do this is to multiply by 1, as shown here: How to check if text input is a number? - #3 by domhnallohanlon
Actually forgot to tell you that it works properly for smaller numbers even if we donât convert it to a number. I did the changes and it shows the output below. I am sceptical that it has some limit on the range of numbers it can check, What is your opinion?
@cc_mindchamp I would guess youâre right, but it would be a max imposed by JavaScript in this case vs anything specifically related to Thunkable.
I did a search on âwhat is the largest number in javascriptâ and that comes back as: 9007199254740991
Testing proves this to be true.
However, validating user input is always best practice, and I would agree with @tatiang 's recommendation to multiply by 1 to ensure youâre dealing with a number.
JavaScript can sometimes misinterpret the operation because + is used for addition and concatenation (joining strings together). Here is a test I ran in the browser console that proves the point:
Thank you both of you @marion.dorsett @tatiang
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.