0

I'm receiving the error

missing ; before statement

This is in reference to

var westvars += ''+ (i+1) +'. '+ el.

Any idea what may be going wrong. I've tried removing the line/reconstructing the line ect. I just can't seem to figure out what part of the string is using an incorrect syntax.

var westvars = '<div class="clear">';
    westvars += '<div class="col-xs-2 teamname"><span>'+ (i+1) +'. '+ el.city +' '+ el.name +'</span>';
    westvars += '</div>';
    westvars += '<div class="col-xs-2 winsloss"><span>'+ el.wins +'-' +el.losses +'</span>';
    westvars += '</div>';
    westvars += '<div class="col-xs-2 gamesback">' + el.gback +';
    westvars += '</div>';
    westvars += '</div>';
4
  • 2
    your re-declaring var over and over. Commented Feb 26, 2015 at 23:41
  • 3
    you have both single and double quotes in that statement Commented Feb 26, 2015 at 23:42
  • 3
    And in your actual code, you have a ' '' on the sixth line. Commented Feb 26, 2015 at 23:43
  • highly recommend to you read about basics and ideology of library before write down something, simply use append method or html and be carefull with quotes, for line-break use backslash. Commented Feb 26, 2015 at 23:44

1 Answer 1

2

Should be changed this way:

var westvars = '<div class="clear">';
westvars += '<div class="col-xs-2 teamname"><span>'+(i+1)+'. '+ el.city +' '+ el.name +'</span>';
westvars += '</div>';
westvars += '<div class="col-xs-2 winsloss"><span>'+ el.wins +'-' +el.losses +'</span>';
westvars += '</div>';
westvars += '<div class="col-xs-2 gamesback">' + el.gback + ' ';
westvars += '</div>';
westvars += '</div>';
Sign up to request clarification or add additional context in comments.

2 Comments

That seemed like it did the trick. Can you let me know which line you made a change to? I just went through it and can't spot the error/errors. Thanks again @Axel
@Chris: every line ;-) in JS the term "var" defines a new variable. Thus var x += 3; must cause an error as xis not defined in the moment the right hand side gets resolved. And you actually had some quoting issues.

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.