Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

JavaScript Console | ...what does it mean?

Dave says the error message indicates the number of the string where the error is, i.e. 1 and 2; mine said "scripts.js: 1:12" and "scripts.js: 2:1". I had already corrected the error without any problem, but I still don't know what those number exactly meant: the first clearly is the number of the line, but the second one? I double checked and it's not the place where the wrong punctuation or letter is.

1 Answer

Jonathan Grieve
MOD
Jonathan Grieve
Treehouse Moderator 91,254 Points

Hi Yasmine,

As you suggest, the numbers refer to the line number and the character position of the error in question.

alert("message")

So in this little example, the line would be line 1 (in fact, the only line in the script, and the error would be at position 17 because it's expecting a semicolon to end the line.

But there are little grey areas in the process and you can't rely on the numbers exactly. for example the console might declare an error on a given line where in fact that part of the code is perfectly okay but you'll have to look for an error on the preceding line.