Unit 5 Hackathon States Data

I am trying to help two student partners with their code. Lines 36 and 37 were their ideas to get the filteredStateNames and filteredStateImages to appear. I tried to use line 38 and 39 to help them but am getting uistring errors. Any thoughts??
They are using the US states data set.

Thanks in advance.

The reason this is happening is that you added an extra comma inside the setText and setImageURL, so the app doesn’t know what to do. From reading your students’ code, it looks like you would instead need to use setText("stateNameText", filteredStateNames[randomNumber(0, filteredStateNames.length)]);
and the same for setImageURL.
However, since setText and setImageURL are both creating random numbers, their results will almost always be different. To change this, create something like this: var randomState = randomNumber(0, filteredStateNames.length;, then replacing your setText and setImageURL with "stateNameText", filteredStateNames[randomState]);

PS: remind your students to always check for spelling errors. In both the setText and setImageURL the filteredStateNames.length was spelt wrong.

Sorry if this was a lot to take in, but I hope it helps your students!

1 Like

There are also two onEvent calls for "filterDropDown". One for click and one for change. Having two doesn’t hurt but click doesn’t work that well with dropdown boxes.

Thanks so much. After a while my mind gets bogged down trouble shooting code.

1 Like