+ 1
Creating a quiz in js and shows error
Greeting everyone, I have this code. I am trying to do like a quiz that shows results based in your answers. It had 50 questions, but when it's at question 33, the code shows error out to me. Untaught TypeError: Cannot read property of undefined In JavaScript How can I solve this The complete code is here https://codepen.io/xxfatj/pen/xxWwRGx
1 ответ
0
At two places in your code you type double "," this make your program dont understand what you type and throw error, check end of this code:
{
q: '33. Eating sweets before bed:',
a: [
{ answer: 'a. Doesn’t keep me from sleeping at all', type: [1] },
{ answer: 'b. Sometimes makes me feel restless in bed', type: [2 ] },
{ answer: 'c. Keeps me up all night', type: [2] },
]
}, , // see here double , , delete one of this and it will work
So question 33 and 45 have this, you probably copy/paste it, because it is array you need one, but you mistype and placed two