I am missing something and can’t seem to figure it out … I have tried changing so many things at this point. I have been changing up how I do my class since there are so many videos out there showing how to do stuff so I gave my students an empty project of the Random Dog Picker and had them write the code… I am missing where the error is with this one as to why it isn’t working.
This project is from AP Computer Science Principles so out of scope for Discoveries. Have the kids covered the topics of lists, loops and traversals?
Here are some tips to try and get you all “unstuck” as well as a link to a solution if you really need help…
The first app has an error on the very first line. My CSP student often made this mistake. When you import a data table, you don’t need the square brackets. I didn’t catch it at first but when I went to test the length of DogBreed list by using console.log(DogBreed.length) - it was 1 but should have been 105. So make sure the table/columns are imported correctly.
The second big cause for error for both apps is the way that the dogSize variable is updated and used. Remember, you want the size variable to:
Update every time it changes
Be accessible by the function that needs it (so either declared in the function OR a global variable).
I believe both of the apps above capture size just one time when the app is initially run but not each time it changes with the dropdown.
HERE is the link to the activity in the CSP curriculum. It does have working code so if you want to try and solve using the tips above first - wait before you take a look .
fair enough, though there was more than just 1 thing wrong with it (at least when i was troubleshooting)… so i just took the liberty to remake it from scratch, my version also allows more flexibility since you could just pass through the whole instance if you wanted more data later in the future and uses less indexing definitely recommend Melynn’s advice though