- This topic is empty.
Viewing 6 posts - 1 through 6 (of 6 total)
Viewing 6 posts - 1 through 6 (of 6 total)
- The forum ‘JavaScript’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
Home › Forums › JavaScript › Help out a beginner?
Hi. I’m very new to Javascript and I’ve been working on a Javascript quiz. I’m learning out of a book called [Javascript & jQuery: The Missing Manual](http://www.amazon.com/JavaScript-jQuery-David-Sawyer-McFarland/dp/1449399029 “View this book on Amazon”) which is where I’m getting the code for the quiz. I’ve checked my code against the book’s code and everything seems to be the same, yet when I test it, my quiz bugs out and the book’s quiz works. Can someone please look at my javascript and find out what the problem is?
Here’s the link to my quiz: http://gchiller.com/testJS/complexQuiz.html
Here’s the link to the book’s quiz: http://gchiller.com/testJS/complete_quiz.html
Someone is missing a comma somewhere?!?!?!
Maybe in an array?
var questions = [
,
<---- MISSING COMMA
];
Also go to jsFiddle and enter your code in the javascript portion, then hit the button on top that says “JSHint”, it will reveal some mistakes :)
@JohnMotylJr : What a relief! Thank you so much for finding that error and for the jsFiddle tip!
a suggestion:
var questions = [
,
,
];
putting the comma *before* the item makes it easier to troubleshoot: they’re all in the same column (whereas they might be in different columns at the end, because each array item has a different length). It’s always helpful to write your code in a way that makes mistakes more obvious.
@traq : Thanks for the advice! I’ll try that.