Link to the project or level:
This is for the Hackathon project. App Lab - Code.org
What I expect to happen: Student wants to be able to select the category and (when the nextButton clicked) for the list to populate into different text areas with the person’s first and last names, country of birth, year of award, category, and motivation. Then when they click anyone else, for it to select a different person from the list for that category (and so forth and so on) until no one is left. Then once the list runs out of people, she wants the newPerson button to direct them to the nomorePeopleScreen.
What actually happens:
WARNING: Line: 94: setText() text parameter value (undefined) is not a uistring.
ERROR: Line: 94: TypeError: Cannot read properties of undefined (reading ‘toString’)
What I’ve tried: I haven’t gotten as involved in this class as I normally do because I am trying to create curriculum for and teach several different classes this year. I just haven’t had the time. I would really, really appreciate it if someone could look at this and maybe help me out. I’m sure it’s something simple that I’ve overlooked…
Hello,
I’m seeing a few errors in this code that are likely tripping up your student. The low hanging fruit:
- On lines 37-42, they are using ‘var’ to redefine their variables rather than to reset the value of their global variable.
- On line 44, the student is getting the person’s name from the dropdown, but they are running this function from the setup() before the user has selected anything.
- On line 46, they are looping through a list that will always be empty, so nothing is put into it.
Together, these errors mean that nothing is being populated in to the lists, so when the setup calls UpdateScreen() it runs into an error trying to access things from the empty filtered lists at index 0 (because that’s the only random number it can generate). The program crashes before the user can ever choose a filtered value.
Hopefully that gives your student a place to continue debugging! I might encourage them to get one list randomly selecting a value first, then build up from there. This is a lot of code to debug and they might have an easier time building up and adding on features rather than trying to build something large from the start!