Link to the project or level: App Lab - Code.org
What I expect to happen: The correct returns should be printed from the console logs
What actually happens: Only one of the functions is producing a return that is being printed
Link to the project or level: App Lab - Code.org
What I expect to happen: The correct returns should be printed from the console logs
What actually happens: Only one of the functions is producing a return that is being printed
Only the last function returns data because it’s the only function that checks the name of the team against the list of teams. The others check the name of the team against some other column, which doesn’t contain team name data and will never find a match.
By changing the first function to look for matches in the team name list, I was able to get it to work correctly:
function nflTeams(teamName) {
var teamList = getColumn("NFL Teams", "Team");
var conferenceList = getColumn("NFL Teams", "Conference");
for (var i = 0; i < teamList.length; i++) {
if (teamName == teamList[i]) {
return conferenceList[i];
}
}
}
It’s also changed to only return a string instead of an array of strings, because there should only ever be one record per team.