var isCorrect = new Array();

function calc(qNo)
{
res1=document.form1.r1[0].checked;
res2=document.form1.r1[1].checked;
res3=document.form1.r1[2].checked;




if(res1)
{
userAns[qNo]=document.form1.r1[0].value;
}
if(res2)
{
userAns[qNo]=document.form1.r1[1].value;
}
if(res3)
{
userAns[qNo]=document.form1.r1[2].value;
}

if(userAns[qNo] == answer[qNo])
{

isCorrect[qNo]=1
}
else
isCorrect[qNo]=0

}

let me explain the whole program to you.

Im creating an assessment engine. Every page contains a question followed by three options (radio buttons). The above function accepts a qNo which is the page no of the respective page (e.g. page1.html,page50.html). res1,res2,res3 is are variables holding the checked or unchecked status of the radio button. If checked the value of the radio box is saved in the array 'userAns'. For e.g.,if the qNo is '5' and the right answer is option 1, then calc(5) would assign 'document.form1.r1[0].value' to userAns[5]. If this userAns[5] is equal to anwer[5](which is already defined inside the js file), then isCorrect[5]=1 or else isCorrect[5]=0. This is to find out whether the user has given the right answer or not. Likewise in everypage, the isCorrect[qNo] is updated to either '0' or '1'. At the end of the test, the result is displayed in a newpage along with a feedback for wrong answers. At this page, the function is:

for(i=1;i<=MAX_QUEST;i++)
{

if(isCorrect[i]==0)
{
document.write('Q.No.'+i+' You did not answer this correct'+'<br>')
document.write(feedBack[i]+'<br>');
}
else
{
document.write('Q.No.'+i+' You answered this question correct'+'<br>');
}
}

This function writes the feedback only for the wrong answers. But the problem is that the isCorrect[qNo] in the last page showing as 'undefined'.

Also for every correct answer, a global variable called 'score' is incremented by 10. But at the last page, the value of score still remains '0' even if all questions are correct.

Can u please suggest a way to retain the value of arrays and variables in everypage?