La variabile score(punteggio) ha all'interno tutti i punteggi delle risposte come valore test, quindi non me li somma.
Come lo posso risolvere? Questo è lo script:
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var ans = new Array;
var done = new Array;
var yourAns = new Array;
var explainAnswer = new Array;
var score = 0;
explainAnswer[1]="PRESSURE: very high and annoying\nMASTERY: nothing\nDEFINITION: situation of breathless time anxiety\n";
explainAnswer[2]="PRESSURE: present but not excessive\nMASTERY: still insufficient\nDEFINITION: situation of blocked dissatisfaction\n";
explainAnswer[3]="PRESSURE: nothing (disinterest )\nMASTERY: nothing ( no action)\nDEFINITION: comprise with clock\n";
explainAnswer[4]="PRESSURE: present but not annoying \nMASTERY: real, but improvable\nDEFINITION: sorganized mastery\n";
explainAnswer[5]="PRESSURE: very high, stressful \nMASTERY: perfect, total\nDEFINITION: situation of breathless time anxiety\n";
function Engine(question, answer) {
yourAns[question]=answer;
}
function Score(){
var answerText = "How did you do?\n------------------------------------\n";
//now score the user
for(i=1;i<=30;i++)
{
score=score+yourAns[i];
}
if(score<=35){
answerText=explainAnswer[1];
}
if(score>35 && score <40){
answerText=answerText+explainAnswer[1]+'\n'+explainAnswer[2];
}
if(score>=40 && score <=50){
answerText=answerText+explainAnswer[2];
}
if(score>50 && score <55){
answerText=answerText+explainAnswer[2]+'\n'+explainAnswer[3];
}
if(score>=55 && score <=65){
answerText=answerText+explainAnswer[3];
}
if(score>65 && score <70){
answerText=answerText+explainAnswer[3]+'\n'+explainAnswer[4];
}
if(score>=70 && score <=80){
answerText=answerText+explainAnswer[4];
}
if(score>80 && score <85){
answerText=answerText+explainAnswer[4]+'\n'+explainAnswer[5];
}
if(score>=85){
answerText=answerText+explainAnswer[5];
}
answerText=answerText+"SCORE: "+score;
alert(answerText);
}
// End -->
</script>