diff --git a/math_practice_1/button.png b/math_practice_1/button.png new file mode 100644 index 0000000..28e00d5 Binary files /dev/null and b/math_practice_1/button.png differ diff --git a/math_practice_1/main.js b/math_practice_1/main.js index 6f08d80..5737020 100644 --- a/math_practice_1/main.js +++ b/math_practice_1/main.js @@ -7,7 +7,7 @@ document.addEventListener('DOMContentLoaded', (event) => { let currentQuestion = {}; let score = 0; -let difficulty = 'easy'; // Default difficulty level +let difficulty = loadSettings().difficulty; // Load difficulty from settings // Initialize the game function initGame() { @@ -94,7 +94,7 @@ function createQuestion(difficulty) { // Check the user's answer function checkAnswer(selectedAnswer) { const feedbackElement = document.getElementById('feedback-message'); - if (selectedAnswer === currentQuestion.correctAnswer) { + if (selectedAnswer == currentQuestion.correctAnswer) { // Use == for type coercion score++; feedbackElement.innerText = 'Correct!'; } else { @@ -110,4 +110,18 @@ function checkAnswer(selectedAnswer) { // Get a random integer between min (inclusive) and max (inclusive) function getRandomInt(min, max) { return Math.floor(Math.random() * (max - min + 1)) + min; +} + +// Load settings from local storage +function loadSettings() { + const settings = localStorage.getItem('gameSettings'); + if (settings) { + return JSON.parse(settings); + } else { + // Default settings + return { + difficulty: 'easy', + sound: true + }; + } } \ No newline at end of file diff --git a/math_practice_1/settings.html b/math_practice_1/settings.html index 6955fe7..b4addfc 100644 --- a/math_practice_1/settings.html +++ b/math_practice_1/settings.html @@ -3,10 +3,15 @@
-