-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
37 lines (31 loc) · 1.53 KB
/
script.js
File metadata and controls
37 lines (31 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
const kindnessActs = [
"Compliment a stranger and make their day.",
"Donate to a local charity or organization.",
"Write a heartfelt letter to a friend or family member.",
"Offer to help someone with their chores or errands.",
"Plant a tree or flowers in a public space.",
"Pay for someone's meal or coffee anonymously.",
"Volunteer your time at a local community center.",
"Send a positive message to someone you haven't talked to in a while.",
"Leave an uplifting note in a public place for someone to find.",
"Bake cookies or treats and share them with your neighbors."
];
function generateRandomAct() {
const kindnessActElement = document.getElementById("kindness-act");
const randomIndex = Math.floor(Math.random() * kindnessActs.length);
const randomAct = kindnessActs[randomIndex];
kindnessActElement.textContent = randomAct;
// Reset the "Great Job" message
document.getElementById("great-job-message").textContent = "";
}
function logKindness() {
const kindnessStreakElement = document.getElementById("kindness-streak");
let kindnessStreak = parseInt(localStorage.getItem("kindnessStreak")) || 0;
// Increment the kindness streak
kindnessStreak++;
localStorage.setItem("kindnessStreak", kindnessStreak);
// Display the streak
kindnessStreakElement.textContent = `Kindness Streak: ${kindnessStreak}`;
// Show "Great Job" message
document.getElementById("great-job-message").textContent = "Great Job today!";
}