admin管理员组文章数量:1289537
I'm trying something with JavaScript. I keep getting this error for the following code block -
"There is a missing ; before statement."
And the statement referred to is the for loop after the function TeamConst
. Any idea why?!
function Semis1TieBreakCheck(){
function TeamConst(TeamName, rd1, rd2, semisb){
this.TeamName = TeamName;
this.rd1 = rd1;
this.rd2 = rd2;
this.semisb = semisb;
};
for(var i = 0; i <= numofTeams-0; i++){
var team[i] = new TeamConst(values[i+2][5],values[i+2][6],values[i+2][7],values[i+2][6] + values[i+2][7]);
};
};
I'm trying something with JavaScript. I keep getting this error for the following code block -
"There is a missing ; before statement."
And the statement referred to is the for loop after the function TeamConst
. Any idea why?!
function Semis1TieBreakCheck(){
function TeamConst(TeamName, rd1, rd2, semisb){
this.TeamName = TeamName;
this.rd1 = rd1;
this.rd2 = rd2;
this.semisb = semisb;
};
for(var i = 0; i <= numofTeams-0; i++){
var team[i] = new TeamConst(values[i+2][5],values[i+2][6],values[i+2][7],values[i+2][6] + values[i+2][7]);
};
};
Share
Improve this question
edited Jul 18, 2014 at 22:59
Volker E.
6,04411 gold badges49 silver badges66 bronze badges
asked Sep 27, 2013 at 0:42
CodeNewbieCodeNewbie
1132 gold badges2 silver badges6 bronze badges
4
- Check the semicolon's after the } – Jared Beekman Commented Sep 27, 2013 at 0:44
-
1
Remove the semi-colon immediately after your
for {}
loop. – user1864610 Commented Sep 27, 2013 at 0:44 - Thank you! It doesn't work still though. – CodeNewbie Commented Sep 27, 2013 at 0:45
-
For me, I mistype
function
asfuntion
(missed ac
character afterfun
), and then this error occured. – LiuYan 刘研 Commented Sep 10, 2015 at 8:49
2 Answers
Reset to default 7You can't declare a property of an object/array using the var
keyword.
Change var team[i] = ...
to just team[i] = ...
.
Also make sure that team is declared somewhere. If it is not already declared in an outer scope then add this before your loop:
var team = [];
I don't get that error, but there is a different one. You need to define team
first.
var team = [];
for (var i = 0; i <= numofTeams-0; i++) {
team.push(new TeamConst(values[i+2][5],
values[i+2][6],
values[i+2][7],
values[i+2][6] + values[i+2][7])
);
};
本文标签: Missingbefore statementJavaScriptStack Overflow
版权声明:本文标题:Missing ; before statement, JavaScript - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741412441a2377315.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论