Daily Code #2

Today on daily posts I will teach you how to make a Health app in JS // Tiny Health Tracker const health = { water: 0, steps: 0, drink: () => health.water++ || console.log(`Drank water! Total: ${health.water}`), walk: s => (health.steps += s) && console.log(`Walked ${s} steps! Total: ${health.steps}`), stats: () => console.log(`Water: ${health.water} glasses | Steps: ${health.steps}`) }; // Example usage: health.drink(); // Drank 1 glass of water health.walk(500); // Walked 500 steps health.stats(); // Shows stats Paste it into your compiler and it will work! Thanks for looking at today’s daily post!

Apr 17, 2025 - 23:23
 0
Daily Code #2

Today on daily posts I will teach you how to make a Health app in JS


// Tiny Health Tracker
const health = {
  water: 0,
  steps: 0,
  drink: () => health.water++ || console.log(`Drank water! Total: ${health.water}`),
  walk: s => (health.steps += s) && console.log(`Walked ${s} steps! Total: ${health.steps}`),
  stats: () => console.log(`Water: ${health.water} glasses | Steps: ${health.steps}`)
};

// Example usage:
health.drink();       // Drank 1 glass of water
health.walk(500);     // Walked 500 steps
health.stats();       // Shows stats

Paste it into your compiler and it will work!

Thanks for looking at today’s daily post!