Parameters javascript参数未定义

Parameters javascript参数未定义,parameters,code.org,Parameters,Code.org,在第16行setText中,它说TypeError:无法读取未定义的属性“toString” 我不知道如何解决这个问题。第30行,最后一个for循环说我已经被定义了,但我不知道如何定义 //lists var teamNames = getColumn("NBA Teams", "Team"); var teamChampionships = getColumn("NBA Teams", "Championship wins&

在第16行setText中,它说TypeError:无法读取未定义的属性“toString” 我不知道如何解决这个问题。第30行,最后一个for循环说我已经被定义了,但我不知道如何定义

//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;
    }
  }
}
//列表
var teamNames=getColumn(“NBA球队”、“球队”);
var TeamChampions=getColumn(“NBA球队”,“锦标赛胜利”);
var teamConference=getColumn(“NBA球队”、“会议”);
//过滤列表
变量filteredNames=[];
OneEvent(“用户按钮”,“单击”,函数(){
updateScreen();
});
//更新屏幕以显示筛选的团队名称
函数updateScreen(){
var textOutput=“”;
var Champosion=getColumn(“NBA球队”,“锦标赛胜利”);
textOutput=findMatches(锦标赛);
setText(“teamsArea”,textOutput);
}
对于(var i=0;i
欢迎来到StackOverFlow:-)

好的,你可能想追溯到,这两行:

var championship = getColumn("NBA Teams", "Championship wins");
textOutput = findMatches(championship);
“getColumn”返回“未定义”或空数组[],或者:

textOutput = findMatches(championship); // returns undefined...
我注意到,“findMatches”函数没有定义的返回值(如果为false)

  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;
          }
      }
      // will return undefined, if for loop never returns "matches"...
   }
功能查找匹配(锦标赛){
var teamNames=getColumn(“NBA球队”、“球队”);
var matches=filteredNames[i];
对于(var i=0;i
没有更多关于标记和其他引用函数(如getColumn、setText等)的说明,这看起来是一个很好的起点

至于第30行。。。这是因为您已经在第18行定义了一个变量“i”,然后在第30行尝试重新定义它

我建议对块和循环使用“let”