I'm working on a carbon calculator using Typeform to ask people a set of questions about Housing, Transport, and more. I need to create a loop based on the answers to previous questions. For example, if a user indicates they have 3 cars, the question group with all the car-related questions should loop 3 times before moving to the next question. If the user has 0 cars, the loop will not execute, and it will jump to next question skipping the question group with all the car-related questions. (see the attached image for the logic).
Problem Description
Question 11: Asks the user how many cars they have.
Question 12: A question group with 4 sub-questions about cars (12.a, 12.b, 12.c, 12.d).
What Works: If the user inputs 0, it correctly directs them to question 13.
Where I Need Help: If the user inputs any number greater than 0, it enters an infinite loop and doesn’t break. Here is the logic I have used:
- I created a NUMBER variable called 'car_count' and initially assigned it the value '0'.
- If the user has more than 0 cars, then it should assign the value of 'cars' (answer of Question 11) to 'car_count'.
LOGIC USED ON QUESTION 11. - If 'cars' is equal to 0, go to Question 13. For all other cases, go to Question Group 12.
- At the end of Question Group 12, specifically in 12.d, I have the following logic set:
- Always subtract 1 from 'car_count'.
- If 'car_count' is greater than 0, go to 12.
- If 'car_count' is equal to 0, go to 13, which should ideally break the loop but instead goes back to 12.


I'm not sure what I'm doing wrong here. I would be really grateful if someone could help me with this.