let state = "problem"; // problem | steps | done let stepIndex = 0; let currentData = null; // Load the data to draw async function loadData() { const res = await fetch("data/data.json"); currentData = await res.json(); state = "problem"; stepIndex = 0; render(); } function render() { if (!currentData) return; const problemEl = document.getElementById("problem"); const stepsEl = document.getElementById("steps"); if (state === "problem") { problemEl.innerHTML = `\\(${currentData.problem}\\)`; stepsEl.innerHTML = ""; } if (state === "step") { problemEl.innerHTML = `\\(${currentData.problem}\\)`; let html = ""; for (let i = 0; i <= stepIndex; i++) { const s = currentData.steps[i]; html += `