Changed around line 1
+ const questions = document.querySelectorAll('.question');
+ const resultSection = document.getElementById('result');
+ const levelTitle = document.getElementById('level-title');
+ const levelDescription = document.getElementById('level-description');
+ const retakeButton = document.getElementById('retake');
+
+ let currentQuestion = 0;
+ let results = [];
+
+ const levels = {
+ basic: {
+ title: "Basic",
+ description: "Start with a simple email marketing tool. Focus on building your list and creating consistent content."
+ },
+ intermediate: {
+ title: "Intermediate",
+ description: "Use a more advanced platform with automation features. Start segmenting your audience and tracking performance."
+ },
+ advanced: {
+ title: "Advanced",
+ description: "Invest in a comprehensive email marketing solution with advanced automation, segmentation, and analytics."
+ }
+ };
+
+ function showQuestion(index) {
+ questions.forEach((question, i) => {
+ question.classList.toggle('active', i === index);
+ });
+ }
+
+ function nextQuestion() {
+ currentQuestion++;
+ if (currentQuestion < questions.length) {
+ showQuestion(currentQuestion);
+ } else {
+ showResult();
+ }
+ }
+
+ function showResult() {
+ const levelCounts = {
+ basic: 0,
+ intermediate: 0,
+ advanced: 0
+ };
+
+ results.forEach(result => {
+ levelCounts[result]++;
+ });
+
+ const finalLevel = Object.keys(levelCounts).reduce((a, b) =>
+ levelCounts[a] > levelCounts[b] ? a : b
+ );
+
+ levelTitle.textContent = levels[finalLevel].title;
+ levelDescription.textContent = levels[finalLevel].description;
+ resultSection.classList.remove('hidden');
+ }
+
+ function resetQuiz() {
+ currentQuestion = 0;
+ results = [];
+ showQuestion(currentQuestion);
+ resultSection.classList.add('hidden');
+ }
+
+ document.querySelectorAll('.options button').forEach(button => {
+ button.addEventListener('click', (e) => {
+ results.push(e.target.dataset.value);
+ nextQuestion();
+ });
+ });
+
+ retakeButton.addEventListener('click', resetQuiz);
+
+ // Initialize first question
+ showQuestion(currentQuestion);