Problem with Updating Score Using List Index in Thunkable – Returns NaN


Hello Thunkable Community,

I’m working on an app where users can select countries from a list, and based on their selection, I need to update a score from another list that matches the selected country. However, I’m encountering an issue where the score is returning as NaN (Not a Number) when I try to calculate it based on the selected index.

Here’s the setup I have:

  • Country List: A list of countries (e.g., Afghanistan, Albania, Algeria, etc.).
  • Score List: A corresponding list of scores (e.g., 5, 4.12, 3.12, etc.).
  • Selected Country: I store the selected country when a list item is clicked.
  • Selected Index: I store the index of the selected country from the country list.
  • Score Update: I try to update a score variable by using the score corresponding to the selected index from the scoreList.

Issues:

  • When I click on a country from the list, it successfully sets the country and index, but the score value is returning as NaN.
  • The issue only arises when using the full list of countries, but works when there’s only a single country.
  • I’m trying to ensure the score is updated by accessing the value from the scoreList based on the index of the selected country.

I’ve checked and verified that the index and country exist in the lists. What might I be missing, and how can I ensure the score is updated correctly without getting NaN?

I have also tried a different way before this my doing it with a sheet which should be easier, apparently not! Please help.

Thanks in advance for your help!

You have a few problems:

  1. Lists should be comma-separated without spaces or quotes. So 5,3.15,3.74,2.52, etc. And Afghanistan,Albania,Algeria, etc.
  2. You can’t make a list from a text string of comma-separated values by attaching it to a list block. That just creates a list with a single item instead of multiple items. You need to use the make list from text block to do that.
  3. Don’t use duplicate list blocks. The in list block is expecting a list but you need to give it a variable that IS a list rather than another list block`. You do this by following #2 above.

Thank you for replying! However, I still have a problem.

Even though the values are correct, when I calculate the score on the next page, the numbers it’s giving me have a 0 before the score. For example, if Afghanistan = 1, it will give me 01. If Albania is 2, it will give me 02 etc. It’s not calculating correctly when I add all scores together.

I honestly don’t know what I am doing wrong, I am new in this.

Thank you in advance for helping me!


Can you post a link to your project? It will be easier for my to debug if I can see all of the blocks and screens.

https://x.thunkable.com/copy/36898c1a3f2d36f1cc75d0e4988d0d96

To better help you understand how my project works:

It consists of 3 different screens.

SCREEN 1: Simple, once you click start, it goes to Screen 2.

SCREEN 2: There are four questions that need to be answered. Question 1 and 4 are multiple choice, each checkbox has a certain value. For example: If you check box number 4 in question 1, the value will be 4. If you check check box number 3 in question 4, the value will be 2.

Questions 2 and 3 have list of countries. Each country has its own value as well. So when each one is selected, the value must be saved as well.

SCREEN 3: That’s where I calculate all values and get a final score.

My main problems were:
Sheets: I tried with Sheets but it would give me an error “undefined”.
List: With lists, I made the values work with your help but the number has a 0 before it and it doesn’t calculate properly.

Thank you!