0

クイズをコーディングしていて、スコアに応じて特定の回答を表示する必要があります。

スコアが表示されたばかりのときにこれが機能していましたが、if else に追加したので、機能しなくなり、未終了の文字列定数を取得しています

$total_score = $first_question + $second_question + $third_question + $fourth_question + $fifth_question + $sixth_question + $seventh_question + $eighth_question + $ninth_question + $tenth_question + $eleventh_question + $twelfth_question + $thirteenth_question + $fourteenth_question + $fifthteenth_question + $sixteenth_question ;
});

$("#btn").click(function() {
   $('#reveal').html("<h3><strong>Total score</strong> " + $total_score +"</h3>"); 

if ($total_score >= 13) {
$('#answer').html("<h3><strong>13-16: Answer</strong></h3>"); 

} else if ($total_score >=9 && $total_score <= 12) {
$('#answer').html("<h3><strong>9-12: answer</strong></h3>"); 

} else if ($total_score >=5 && $total_score <= 8) {
$('#answer').html("<h3><strong>5-8: answer</strong></h3>"); 


 } else {
 $('#answer').html("<h3><strong> everything else</strong></h3>"); 
 }

});
4

2 に答える 2