Changed around line 1
+ document.getElementById('relationshipQuiz').addEventListener('submit', function(event) {
+ event.preventDefault();
+
+ const q1 = parseInt(document.getElementById('q1').value);
+ const q2 = parseInt(document.getElementById('q2').value);
+ const q3 = parseInt(document.getElementById('q3').value);
+ const q4 = parseInt(document.getElementById('q4').value);
+
+ const totalScore = q1 + q2 + q3 + q4;
+
+ let advice = '';
+ if (totalScore <= 6) {
+ advice = 'It might be best to reconsider this relationship. Your well-being should always come first.';
+ } else if (totalScore <= 10) {
+ advice = 'There are some concerns, but with open communication, you might be able to work through them.';
+ } else {
+ advice = 'Your relationship seems positive. Continue to nurture it with honesty and mutual respect.';
+ }
+
+ document.getElementById('scoreText').textContent = `Your score: ${totalScore}`;
+ document.getElementById('adviceText').textContent = advice;
+ document.getElementById('quiz').classList.add('hidden');
+ document.getElementById('result').classList.remove('hidden');
+ });
+
+ document.getElementById('retry').addEventListener('click', function() {
+ document.getElementById('quiz').classList.remove('hidden');
+ document.getElementById('result').classList.add('hidden');
+ });