# Sum of two numbers on thunkable returning "NaN"

**URL:** <https://community.thunkable.com/t/sum-of-two-numbers-on-thunkable-returning-nan/1202744>\
**Category:** Questions about Thunkable X\
**Created:** [April 2, 2021, 6:40pm UTC](https://community.thunkable.com/t/sum-of-two-numbers-on-thunkable-returning-nan/1202744 "2021-04-02T18:40:13Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![taiskleinoliveira8y3](https://avatars.discourse-cdn.com/v4/letter/t/c67d28/32.png) [@taiskleinoliveira8y3](https://community.thunkable.com/u/taiskleinoliveira8y3)\
**Post date:** [April 2, 2021, 6:40pm UTC](https://community.thunkable.com/t/sum-of-two-numbers-on-thunkable-returning-nan/1202744/1 "2021-04-02T18:40:13Z")

</div>

Hi everyone! I am having issues with this block on thunkable X. Could somebody help me please?

I have two numbers saved on variables called “app variable qtd antiga” and “app variable botão+ naked” and I need to sum both of them, but it returns “NaN”.

Does someone know why?

Thank you so much!

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/5/a/5addea593dc1208cd0e9284c38e35f4173ca0fae.png)

---

<div class="post-metadata">

**Author:** ![catsarisky](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/catsarisky/32/100661_2.png) [@catsarisky](https://community.thunkable.com/u/catsarisky)\
**Post date:** [April 2, 2021, 6:46pm UTC](https://community.thunkable.com/t/sum-of-two-numbers-on-thunkable-returning-nan/1202744/2 "2021-04-02T18:46:42Z")

</div>

One of them isn’t a number. Try displaying each separately in a label?

---

<div class="post-metadata">

**Author:** ![taiskleinoliveira8y3](https://avatars.discourse-cdn.com/v4/letter/t/c67d28/32.png) [@taiskleinoliveira8y3](https://community.thunkable.com/u/taiskleinoliveira8y3)\
**Post date:** [April 2, 2021, 7:03pm UTC](https://community.thunkable.com/t/sum-of-two-numbers-on-thunkable-returning-nan/1202744/4 "2021-04-02T19:03:07Z")

</div>

Thank you for answering me!

Yes, it returns that the app variable “qtd antiga” is not a number, but I initialize this variable to number 1 and I set this variable to a number from the list “app variable Lista Contador”. I dont know why is this not a number

 ![WhatsApp Image 2021-04-02 at 15.59.40](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/3/2/32728e432819f872899b0c9ff8e2e9c1cbe540df.jpeg)

---

<div class="post-metadata">

**Author:** ![catsarisky](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/catsarisky/32/100661_2.png) [@catsarisky](https://community.thunkable.com/u/catsarisky)\
**Post date:** [April 2, 2021, 7:35pm UTC](https://community.thunkable.com/t/sum-of-two-numbers-on-thunkable-returning-nan/1202744/5 "2021-04-02T19:35:18Z")

</div>

Without knowing what all the variables are (there are several I don’t see defined in the screenshot), it’s hard to identify the problem. Two thoughts:

1. add a 1s wait block between existing blocks. Occasionally, I’ve seen it where the setting action in the previous block isn’t done before the next block starts, which might explain it. Easy to try, anyway.

2. Do more debugging. You know you’re getting to the end with a NaN value. Add a “set label’s text” at a bunch of intermediate steps. Hopefully you’ll easily spot where things go wrong.

---

<div class="post-metadata">

**Author:** ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)\
**Post date:** [April 2, 2021, 7:52pm UTC](https://community.thunkable.com/t/sum-of-two-numbers-on-thunkable-returning-nan/1202744/6 "2021-04-02T19:52:11Z")

</div>

I would add another suggestion as “a good guideline” although may not be the cause of the issue here.

- Avoid using “+” in the variable name as it could result in unexpected results in some situations.

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [April 2, 2021, 10:15pm UTC](https://community.thunkable.com/t/sum-of-two-numbers-on-thunkable-returning-nan/1202744/7 "2021-04-02T22:15:13Z")

</div>

Most likely, you need to convert those two values to numbers by adding zero to each before you try to get the sum. If that still doesn’t work, then you need to check the value of each variable using a label first.

---

<div class="post-metadata">

**Author:** ![taiskleinoliveira8y3](https://avatars.discourse-cdn.com/v4/letter/t/c67d28/32.png) [@taiskleinoliveira8y3](https://community.thunkable.com/u/taiskleinoliveira8y3)\
**Post date:** [April 2, 2021, 10:43pm UTC](https://community.thunkable.com/t/sum-of-two-numbers-on-thunkable-returning-nan/1202744/9 "2021-04-02T22:43:04Z")

</div>

Thank you for answering it! I added the zero before I tried to get the sum. The problem is that when I get the first occurence of an item from a list “Lista Produtos”, it returns a number. But then, when I set a variable called “qtd antiga” to get the item from this position from a list, that is a number, it returns “NaN”. It doesn’t make any sense…

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/3/a/3a250a816715dd0339fa16dbb971af5e3538fc6a.png)

---

<div class="post-metadata">

**Author:** ![convickto0bed4](https://avatars.discourse-cdn.com/v4/letter/c/e99b99/32.png) [@convickto0bed4](https://community.thunkable.com/u/convickto0bed4)\
**Post date:** [April 2, 2021, 10:58pm UTC](https://community.thunkable.com/t/sum-of-two-numbers-on-thunkable-returning-nan/1202744/10 "2021-04-02T22:58:11Z")

</div>

Oi taiskleinoliveira8y3  
Pelo seu código imagino que fale português né?  
Você conhece alguma comunidade brasileira de thunkable?  
Aqui é bom, mas é raro encontrar “BR”.  
Eu ouvi dizer que o thunkable classico vai acabar, ou que o google não vai mais dar suporte aos apps criados com ele, por causa da API 29.  
É verdade isso?  
Será que vale a pena migrar pro thunkable x?

---

<div class="post-metadata">

**Author:** ![taiskleinoliveira8y3](https://avatars.discourse-cdn.com/v4/letter/t/c67d28/32.png) [@taiskleinoliveira8y3](https://community.thunkable.com/u/taiskleinoliveira8y3)\
**Post date:** [April 2, 2021, 11:02pm UTC](https://community.thunkable.com/t/sum-of-two-numbers-on-thunkable-returning-nan/1202744/12 "2021-04-02T23:02:47Z")

</div>

Oii! Sim, falo português! Nao conheço comunidade de brasileiros, mas seria bem bom encontrar haha. Olha, não sei mesmo… eu comecei direto no thunkable X, nunca usei o clássico, porque queria criar direto pra IOS junto com android. Mas acredito que dê pra perguntar no chat do thunkable pros profissionais do thunkable mesmo!

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [April 3, 2021, 5:32am UTC](https://community.thunkable.com/t/sum-of-two-numbers-on-thunkable-returning-nan/1202744/13 "2021-04-03T05:32:59Z")

</div>

You have to convert **both** variables to numbers, not just one. So it should be [0 + app variable qtd antiga] + [0 + app varialbe botao+ naked]

---

<div class="post-metadata">

**Author:** ![taiskleinoliveira8y3](https://avatars.discourse-cdn.com/v4/letter/t/c67d28/32.png) [@taiskleinoliveira8y3](https://community.thunkable.com/u/taiskleinoliveira8y3)\
**Post date:** [April 3, 2021, 1:07pm UTC](https://community.thunkable.com/t/sum-of-two-numbers-on-thunkable-returning-nan/1202744/15 "2021-04-03T13:07:13Z")

</div>

Thanks! But is still not working…

I put everything with “0+”, but the “app variable qtd antiga” is still “NaN”. The “app variable botao+naked” is a number and I can do other calculation with it.

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/a/b/ab2cdbb884af7cce31383775f92e2e6637a53fa5.png)

However, when I change the block below  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/6/7/675cf2e655cd601e54ff6063d0fce1b64c9b02e6.png)  
For this:  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/f/f/ff15e9c7fcbe9281f46f6038de90f5c0738085eb.png)

Than, it returns a number. Then, I think the problem is in “app variable teste final”, but I dont know what is wrong.

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [April 3, 2021, 4:06pm UTC](https://community.thunkable.com/t/sum-of-two-numbers-on-thunkable-returning-nan/1202744/16 "2021-04-03T16:06:14Z")

</div>

Then you have to debug the app variable teste final. Figure out where you’re setting it’s value. Either post a screenshot of those blocks or a link to your project.

---

<div class="post-metadata">

**Author:** ![jane](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jane/32/27575_2.png) [@jane](https://community.thunkable.com/u/jane)\
**Post date:** [April 7, 2021, 9:00am UTC](https://community.thunkable.com/t/sum-of-two-numbers-on-thunkable-returning-nan/1202744/17 "2021-04-07T09:00:24Z")

</div>

Hi there,

I can see that you’re setting **qtd angia** to:

`in list [app variable Lista Contador] get # (in list [app variable Lista Produtos] find first occurrence of item [j]) + 0`

I would like to ask about the variable **j** here. This block is usually used when you are iterating through a list, but I can see that there is no `for each item j in list` block here. I also don’t see a block where the value of **j** is set in this screenshot.

What value do you expect **j** to have in these blocks?

---

<div class="post-metadata">

**Author:** ![ioannis](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/ioannis/32/146956_2.png) [@ioannis](https://community.thunkable.com/u/ioannis)\
**Post date:** [November 8, 2024, 1:25pm UTC](https://community.thunkable.com/t/sum-of-two-numbers-on-thunkable-returning-nan/1202744/18 "2024-11-08T13:25:31Z")

</div>



---

<div class="post-metadata">

**Author:** ![matt\_conroy](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/matt_conroy/32/150843_2.png) [@matt\_conroy](https://community.thunkable.com/u/matt_conroy)\
**Post date:** [December 19, 2024, 5:00pm UTC](https://community.thunkable.com/t/sum-of-two-numbers-on-thunkable-returning-nan/1202744/19 "2024-12-19T17:00:37Z")

</div>


