web hosting and development forums
Web Design and Development Forums Archive


Index - JavaScript forum

Array problem


Post reply

Hi guys
I need help on another problem now, this time with arrays.
I've created this array:
Code:
var numberOfQuestions
var examScores
numberOfQuestions=parseFloat(window.prompt('How many questions are there in this exam?',''))
examScores=new Array(numberOfQuestions);
for (var score =0; score<numberOfQuestions; score=score + 1)
{
examScores[score] = window.prompt('Enter your scores for each exam question','')
}
document.write('<BR>' + '<BR>');
document.write('These are the scores for each question in the exam');
for (var score = 0; score < numberOfQuestions; score = score + 1)
{
document.write('<BR>' + examScores[score])
}

Now this seems to work OK and should prompt the user for the number of questions in the exam, it should then prompt the user to enter the score to each question and then print out each of the scores.
I now have to prompt the user to enter the score for a specific question e.g. question no 2, and then print out the correct score opposite the correct number. I know it should use a parallel array but everything I've tried just won't work.
Can anyone help?
Don't worry guys I got this one myself. I think I overstated the requirements, the idea was only to create a more meanigfull input, in the end it only required tweaking of the code presented above.




Dubai Forum | Paris Forum | Webmaster Forum | Vegan Forum | Brisbane Forum | 3D Forum | Jobs in Dubai | Jobs in London | London UK Classifieds
Archive script by RedHo.com