# Unit 5 Hackathon - Why don't the lists fill?

**URL:** https://forum.code.org/t/unit-5-hackathon-why-dont-the-lists-fill/36120
**Category:** Coding and Debugging Help
**Tags:** csp-unit-5
**Created:** [March 31, 2022, 11:17pm UTC](https://forum.code.org/t/unit-5-hackathon-why-dont-the-lists-fill/36120 "2022-03-31T23:17:46Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![tuscj001](https://avatars.discourse-cdn.com/v4/letter/t/a3d4f5/32.png) [@tuscj001](https://forum.code.org/u/tuscj001)
#### Post date: [March 31, 2022, 11:17pm UTC](https://forum.code.org/t/unit-5-hackathon-why-dont-the-lists-fill/36120/1 "2022-03-31T23:17:46Z")

</div>

Hello,  
I can’t figure out why the values from the filter won’t fill the lists in the function “standingsFilter”. Can anyone tell me what I’m missing please? Thanks in advance for your help.

//Pull the columns needed and put them in a list variable  
var yearsList = [(getColumn(“Baseball Teams”, “Year”))];  
var ranksList = [(getColumn(“Baseball Teams”, “Rank”))];  
var teamsList = [(getColumn(“Baseball Teams”, “Team Name”))];  
var fieldList = [(getColumn(“Baseball Teams”, “Baseball Field”))];

//create empty lists for filtered columns  
var filteredYearsList = ;  
var filteredRanksList = ;  
var filteredTeamsList = ;  
var filteredFieldList = ;

//Event handler fires the filter on any change to the dropdown menu  
onEvent(“teamDropdown”, “change”, function( ) {  
standingsFilter();  
});

//Filter by team finishes  
function standingsFilter() {

//empty the lists  
filteredYearsList = ;  
filteredRanksList = ;  
filteredTeamsList = ;  
filteredFieldList = ;

//put the dropdown menu choice into a variable  
var choice = getText(“teamDropdown”);

//then run the loop and the filter to fill the lists  
for (var i = 0; i \< teamsList.length; i++) {  
if (choice == teamsList[i]) {  
appendItem(filteredYearsList, yearsList[i]);  
appendItem(filteredRanksList, ranksList[i]);  
}  
}  
}

---

<div class="post-metadata">

### Author: ![bhatnagars](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/bhatnagars/32/4919_2.png) [@bhatnagars](https://forum.code.org/u/bhatnagars)
#### Post date: [March 31, 2022, 11:54pm UTC](https://forum.code.org/t/unit-5-hackathon-why-dont-the-lists-fill/36120/2 "2022-03-31T23:54:46Z")

</div>

Hello,

In accordance with the College Board’s guidelines for AP CS Principles Exam, we limit the debugging assistance we provide from March through the submission deadline for the Create Task.

From page 14 of the CB’s student handouts:

> “you may not seek assistance in writing, revising, amending, or correcting your work, including debugging the program, writing or designing functionality in the program, testing the program, or making revisions to the program, from anyone other than your collaborative partner(s). "

**Please verify this project is not part of a student’s Create Task for AP CS Principles.**

If it is, we can only verify whether there is a technical issue with the platform causing the bug. If it is not, we are happy to help locate the bug and provide guidance on fixing it!

If it is not, please provide the following information

**Link to the project or level:** [replace with link to the curriculum or get the “Share” link to a project]  
**What I expect to happen:** [replace with a detailed description of the behavior you’re trying to create]  
**What actually happens:** [replace with a detailed description of what actually happens when the code runs including any errors or unexpected behavior]  
**What I’ve tried:** [replace with a detailed description of what you’ve already tried to do to solve the problem]

I will move this post to the debugging category so that we keep an eye out for it.

Thank you!

---

<div class="post-metadata">

### Author: ![tuscj001](https://avatars.discourse-cdn.com/v4/letter/t/a3d4f5/32.png) [@tuscj001](https://forum.code.org/u/tuscj001)
#### Post date: [April 1, 2022, 11:33am UTC](https://forum.code.org/t/unit-5-hackathon-why-dont-the-lists-fill/36120/3 "2022-04-01T11:33:35Z")

</div>

Hello,

I can absolutely guarantee that this is NOT a part of a student’s CS Principles Performance Task. It is the “hackathon” assignment at the end of Unit 5.

Link to the project or level: [//studio.code.org/s/csp5-2021/lessons/17/levels/1?login\_required=true](https://studio.code.org/s/csp5-2021/lessons/17/levels/1?login_required=true)  
**What I expect to happen:** I expected the filter to fill the lists filteredYearsList and  
**What actually happens:** When I use watcher, it returns an empty list. When I use console log, nothing happens. This is the same issue happening throughout the class in multiple projects, so I’m assuming I’m teaching something incorrectly.  
**What I’ve tried:** I’ve moved the “choice” variable to about 5 different locations in the program, I’ve checked the [code.org](http://code.org) guidance on the subject. I’ve sought other solutions through online sources. I’ve rewritten this code about 6 times.

Thanks in advance for any help you can provide. I just want to give my students the correct information. Thanks.

---

<div class="post-metadata">

### Author: ![bhatnagars](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/bhatnagars/32/4919_2.png) [@bhatnagars](https://forum.code.org/u/bhatnagars)
#### Post date: [April 1, 2022, 4:17pm UTC](https://forum.code.org/t/unit-5-hackathon-why-dont-the-lists-fill/36120/4 "2022-04-01T16:17:07Z")

</div>

Please hit the Share button on the top left corner and provide the link that pops up. The link you provided does not show your student’s code.

![image](https://us1.discourse-cdn.com/flex016/uploads/codeorgforum/original/2X/6/67df2a8428ce59e00a21d53ee506125ace33090a.png)

---

<div class="post-metadata">

### Author: ![jdonwells](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/jdonwells/32/7900_2.png) [@jdonwells](https://forum.code.org/u/jdonwells)
#### Post date: [April 2, 2022, 7:02pm UTC](https://forum.code.org/t/unit-5-hackathon-why-dont-the-lists-fill/36120/5 "2022-04-02T19:02:46Z")

</div>

> [@getColumn: one common error and one subtle error explained](https://forum.code.org/t/getcolumn-one-common-error-and-one-subtle-error-explained/34355):
>
> The most common error with getColumn by far seems to be wrapping it in []s. You end up with an array (returned by getColumn) inside an array (created by []) and that doesn’t do what you want at all. So just write var cats = getColumn("Cats","Name");. No ( )s and no []s. I wrote a more complete explanation here [Everything You Wanted to Know About App Lab Arrays, But Were Afraid to Ask](https://forum.code.org/t/everything-you-wanted-to-know-about-app-lab-arrays-but-were-afraid-to-ask/34277). The subtle error that can result is a race condition. A race condition happens when you have two or more s…

---

<div class="post-metadata">

### Author: ![tuscj001](https://avatars.discourse-cdn.com/v4/letter/t/a3d4f5/32.png) [@tuscj001](https://forum.code.org/u/tuscj001)
#### Post date: [April 4, 2022, 1:21pm UTC](https://forum.code.org/t/unit-5-hackathon-why-dont-the-lists-fill/36120/6 "2022-04-04T13:21:03Z")

</div>

Good morning, and THANK YOU for taking the time to help out. We did as you recommended and rewrote to launch the filter action as a result of using the dropdown, which should avoid the “race condition.” Unfortunately, still no luck.  
Just to check everything:

- I ran a console log to be sure the lists fill correctly, and they are.

- I ran a console log to verify that the “filtered lists” are empty and they are.

- I ran a console log to make sure the dropdown was passing the value to the variable “choice” and it is.

---

<div class="post-metadata">

### Author: ![bhatnagars](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/bhatnagars/32/4919_2.png) [@bhatnagars](https://forum.code.org/u/bhatnagars)
#### Post date: [April 4, 2022, 3:00pm UTC](https://forum.code.org/t/unit-5-hackathon-why-dont-the-lists-fill/36120/7 "2022-04-04T15:00:20Z")

</div>

Please hit the Share button on the top left corner and provide the link that pops up. The link you provided does not show your student’s code. We can better assist you if we can see and trace the code.

![image](https://us1.discourse-cdn.com/flex016/uploads/codeorgforum/original/2X/6/67df2a8428ce59e00a21d53ee506125ace33090a.png)

---

<div class="post-metadata">

### Author: ![tuscj001](https://avatars.discourse-cdn.com/v4/letter/t/a3d4f5/32.png) [@tuscj001](https://forum.code.org/u/tuscj001)
#### Post date: [April 4, 2022, 3:22pm UTC](https://forum.code.org/t/unit-5-hackathon-why-dont-the-lists-fill/36120/8 "2022-04-04T15:22:54Z")

</div>

Here is the link: [App Lab - Code.org](https://studio.code.org/projects/applab/y7zjP3HqXqb4NLdMblkDw7G1n-tpfcrhdJUYDLplWxQ)

Thanks again. Really don’t know why these lists are not filling. 😠

---

<div class="post-metadata">

### Author: ![bhatnagars](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/bhatnagars/32/4919_2.png) [@bhatnagars](https://forum.code.org/u/bhatnagars)
#### Post date: [April 4, 2022, 4:04pm UTC](https://forum.code.org/t/unit-5-hackathon-why-dont-the-lists-fill/36120/9 "2022-04-04T16:04:50Z")

</div>

Remove the square brackets in lines 1-4. Line 1 should look like this

var yearsList = (getColumn(“Baseball Teams”, “Year”));

---

<div class="post-metadata">

### Author: ![tuscj001](https://avatars.discourse-cdn.com/v4/letter/t/a3d4f5/32.png) [@tuscj001](https://forum.code.org/u/tuscj001)
#### Post date: [April 4, 2022, 6:28pm UTC](https://forum.code.org/t/unit-5-hackathon-why-dont-the-lists-fill/36120/10 "2022-04-04T18:28:13Z")

</div>

That did it! Thank you @bhatnagars!

For folks who read this later on, and - App Lab puts those brackets in when it is in “blocks” mode, so they will need to be removed manually. That certainly made the issue more difficult to find. And it’s in the “filter” example in the CS Principles “examples,” so I hope [code.org](http://code.org) can take a look at that. Thank you again!
