Student doing practice Create Task

[Posts in the debugging category need to have the following pieces of information included in order to help other teachers or our moderator team best help you. Feel free to delete everything in brackets before posting your request for debugging help.]

Link to the project or level: https://studio.code.org/projects/applab/67lEdyMybTCiRbs0tr-RRG_BUMZ7Ii7ohmuQBTqZ3vk
**What I expect to happen:**His program works for the first few times you click on the airports, but then if you click multiple times it no longer works
What actually happens: It shows a number and not the airport after several inputs
Is this a bug or a problem with his code?
P.S. I am not sure if the share button will show his data sets he uses

1 Like

Hi @lalamillo,

It looks like your student is creating lists and appending things to them, but not ever removing content. This means that every time their user clicks one of the buttons, the list gets longer and longer (and if the year changes, may not accurately represent the airport statistics). I’m not sure why this is breaking the airport name completely - it could be that app lab has a maximum list size, or that there is in fact an empty string that gets added to the list and is being sent to the user?

Looking at the issue though, this looks like a great opportunity to have a conversation about local vs global variables. Because they’re using global variables they’re carrying info over from one event trigger to the next. Given that they want to calculate this anew each time, I would encourage them to consider which variables should be local and which function they should go in to in order to avoid this redundancy.

2 Likes

It appears to be working now after Madeline’s advise.

There is an opportunity here to talk about using indexes as a way to remember a specific airport. That is, instead of remembering the number of passengers you would remember the index of the lowest or highest number of passengers. That way you don’t need to search for it later.