Then further down, it says, expected one space between end [ and /, expected one space between / and 100, expected one space between ( and /, and so on, and so on, and so on, and so on. The thing is, this stuff, about the space between the characters, does not matter, at all, because my code will likely be minified before it's released on the web, in which case, all white space will be removed. Even so, the tool spends a ton of lines telling me everything is wrong.
And then we have all these timer variables, so at the top here, I say var timer, all of those errors go away, and finally text match on line 34, since it's unused I can just get rid of it, and now I have much better code. If I now highlight all this code, if I go back to JSLint now, and paste in the code, and run JSLint again, you'll see I still get a ton of errors. Here's the thing, as an exercise, it's a good idea to take your script, put it into JSLint, and clean it up to the point where JSLint says that the script is perfect.
However, what you'll see when you do that is it takes a ton of time, and there are a lot of opinions that are being imposed on you by JSLint that may not make a lot of sense. Therefor, use this tool as an exercise, and use it to check if your code is roughly where it needs to be, but if you're looking for actual code quality and errors in your code, use a tool like JSHint instead. Using either of these tools on your code will help you learn how to write better code and clean up any mistakes or oversights or bad habits before shipping that code.
And if copying and pasting into an online tool like this seems like a bit of a hassle, don't worry. In the next movie I'll highlight some tools to automate this process.
- Working with data
- Using functions and objects
- Changing DOM elements
- Handling events
- Working with loops
- Making images responsive using markup
- Troubleshooting code
- Validating functionality