2

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, semiscomb){
        this.TeamName = TeamName;
        this.rd1 = rd1;
        this.rd2 = rd2;
        this.semiscomb = semiscomb;
      };

      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]);
      };

    };
4
  • Check the semicolon's after the } Commented Sep 27, 2013 at 0:44
  • 1
    Remove the semi-colon immediately after your for {} loop. Commented Sep 27, 2013 at 0:44
  • Thank you! It doesn't work still though. Commented Sep 27, 2013 at 0:45
  • For me, I mistype function as funtion(missed a c character after fun), and then this error occured. Commented Sep 10, 2015 at 8:49

2 Answers 2

7

You 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 = [];
Sign up to request clarification or add additional context in comments.

Comments

1

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])
            );                                                                                                            
}; 

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.