In line 16, setText, it says that TypeError: Cannot read property 'toString' of undefined and im not sure how to fix that. Also line 30, the last for loop says that i is already defined but im not sure how.
//lists
var teamNames = getColumn("NBA Teams", "Team");
var teamChampionships = getColumn("NBA Teams", "Championship wins");
var teamConference = getColumn("NBA Teams", "Conference");
//filteredList
var filteredNames = [];
onEvent("userButton", "click", function( ) {
updateScreen();
});
//updates screen to show filtered team names
function updateScreen(){
var textOutput = "";
var championship = getColumn("NBA Teams", "Championship wins");
textOutput = findMatches(championship);
setText("teamsArea", textOutput);
}
for (var i = 0; i < teamNames.length; i++) {
if (teamConference == getText("conferenceDropdown") && teamChampionships == getNumber("championshipInput")) {
appendItem(filteredNames, teamNames[i]);
}
}
//macthes data input with teams and returns it
//championship (integer) - user inputs numbert of championshops
//matches (string) - name of matching teams based on inputed date
function findMatches(championship) {
var teamNames = getColumn("NBA Teams", "Team");
var matches = filteredNames[i];
for (var i = 0; i < teamNames.length; i++) {
if (championship == getNumber("championshipInput")) {
return matches;
}
}
}
welcome to StackOverFlow :-)
Ok, so you may want to trace things back to, these two lines:
Either 'getColumn' is returning "undefined" or an empty array [] or:
I noticed that the "findMatches" function does not have a defined return value, if false.
Without more clarification as to the markup and the remainder of the referenced functions such as getColumn, setText, etc. That looks like a good place to start.
As for line 30... that is because you already defined a variable "i" on line 18, and then on line 30 attempt to redefine it...
I would suggest using "let" for blocks and loops 'let'...