Student app troubleshoot

Student work- need help: Unit 5 Hack-a-thon]

Link to the project or level: App Lab - Code.org)

What I expect to happen: Student is trying to randomly select a president (from 1900 to present) and have the correct data placed into the “Name” and “Home State” areas
What actually happens: SHows as UNDEFINED
What I’ve tried: making it worse:)

In the for loop on line 20, it isn’t looping or running the code because presidentsNameList has to have the .length at the end. Without it, the variable i is being compared to the whole list instead of how long it is, resulting in the arrays not being filtered and the undefined :slight_smile:

On line 20,

for (var i = 0; i < presidentsNameList; i++) {

Becomes:

for (var i = 0; i < presidentsNameList.length; i++) {
1 Like

Thank you for your response and the time you took to explain. The student was able to modify and fix very quickly. We both appreciate the help!

1 Like