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]);
}
}
}
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!
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
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 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.
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.
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.
Then, two lines later, the filter runs, and…nothing. Zip. Nada. Inside the same function. But the list variables are global. I’m really confused. I’m so sorry.
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.
Here is the link: App Lab - Code.org
Thanks again. Really don’t know why these lists are not filling.
Remove the square brackets in lines 1-4. Line 1 should look like this
var yearsList = (getColumn(“Baseball Teams”, “Year”));
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 can take a look at that. Thank you again!