I got this error and dont know what could be the cause. Any idea?
Problem at line 2127 character 18: Bad for in variable 'sport'. for (sport in sugested_sports)
// make array
var sugested_sports = data.split(",");
// pre build DIV
var sporty_items = '';
for (sport in sugested_sports)
{
if (sugested_sports.hasOwnProperty(sport)) {
sporty_items += '<a href="#'+identifier[1]+'">'+sugested_sports[sport]+'</a>';
}
}
// insert DIV
DIVsuggestions.html(sporty_items);
thx alot.
JSLint is a static code analysis tool used in software development for checking if JavaScript source code complies with coding rules. It is provided primarily as a browser-based web application accessible through the domain jslint.com, but there are also command-line adaptations.
ESLint: The fully pluggable JavaScript code quality tool. A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease; JSLint: A Code Quality Tool for Javascript.
The "use strict" Directive It is not a statement, but a literal expression, ignored by earlier versions of JavaScript. The purpose of "use strict" is to indicate that the code should be executed in "strict mode". With strict mode, you can not, for example, use undeclared variables.
Try
var sport;
for (sport in sugested_sports)
This takes care of the missing variable declaration and places it outside the for loop ( see jsLint error "Cannot set property 'first' of undefined" ).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With