I can't answer your query, but I would point out that your test is insecure. Anyone who knows how to display the source code of a web page can find the correct answers! E.g. (I've starred out the actual answers):
// Insert answers to questions
answers = "****";
answers = "*** ******";
and so on...
The marking should be done server-side, not client-side, to make it more difficult to access.