Changed around line 1
+ document.addEventListener('DOMContentLoaded', function() {
+ const sections = document.querySelectorAll('section');
+ const buttons = document.querySelectorAll('button[data-next]');
+ const resultSection = document.getElementById('result');
+ const careerResult = document.getElementById('careerResult');
+ const restartButton = document.getElementById('restart');
+
+ buttons.forEach(button => {
+ button.addEventListener('click', function() {
+ const nextSectionId = this.getAttribute('data-next');
+ sections.forEach(section => {
+ section.classList.add('hidden');
+ });
+ if (nextSectionId === 'result') {
+ const path = getCareerPath();
+ careerResult.textContent = path;
+ resultSection.classList.remove('hidden');
+ } else {
+ document.getElementById(nextSectionId).classList.remove('hidden');
+ }
+ });
+ });
+
+ restartButton.addEventListener('click', function() {
+ sections.forEach(section => {
+ section.classList.add('hidden');
+ });
+ document.getElementById('intro').classList.remove('hidden');
+ });
+
+ function getCareerPath() {
+ const activeSection = document.querySelector('section:not(.hidden)');
+ const activeButton = activeSection.querySelector('button[data-next="result"]');
+ return activeButton ? activeButton.textContent : 'Unknown Career Path';
+ }
+ });