Need help fetching new element (question) from an array for a quiz application

Hey guys,

I created this little quiz app from jQuery and Ajax:

https://codepen.io/techblazes/pen/VwwxYoq

Everything is working as it should. However I am unable to figure out how to display next question to user while the timer is running?

I tried adding this line with +1 for the random number in the if statement at line 14.

$(’.randomQuestion’).text(response[randomNumber+1].question);

that gives me a new question but again the answer goes wrong since answer is looked for in the same index as randomNumber but new question is randomNumber + 1

I’d really appreciate any help with this.

So… add 1 to randomNumber instead? You can change the value of variables. S’kinda in the name.

Hi @m_hutley

Apologies for the late reply. I was caught up in some stuff. Do you mean to say that I should add +1 to randomNumber at line 13 as well?