forked from GCA-Classroom/WD-LL7-DuoLingo-Student-Starter
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscript.js
More file actions
24 lines (21 loc) · 878 Bytes
/
script.js
File metadata and controls
24 lines (21 loc) · 878 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
let xpTotal = 0;
const xpRewards = [10, 15, 20];
const xpDisplay = document.getElementById("xp-total");
const button = document.getElementById("complete-lesson");
const feedback = document.getElementById("feedback");
button.addEventListener("click", function () {
const earnedXP = xpRewards[Math.floor(Math.random() * xpRewards.length)];
xpTotal += earnedXP;
xpDisplay.textContent = xpTotal;
// Conditional outcomes (example solution)
if (xpTotal < 50) {
feedback.textContent = `Nice start! You earned ${earnedXP} XP 👍`;
feedback.className = "good text-center";
} else if (xpTotal >= 50 && xpTotal < 100) {
feedback.textContent = `You're on a streak! 🔥 +${earnedXP} XP`;
feedback.className = "mid text-center";
} else {
feedback.textContent = `LEVEL UP! 🎉 You're crushing it!`;
feedback.className = "great text-center";
}
});