DEV Community

Zako Mako
Zako Mako

Posted on

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

Enter fullscreen mode Exit fullscreen mode

Paste it into your compiler and it will work!

Thanks for looking at today’s daily post!

Top comments (2)

Collapse
 
mannahil_huzaifa_5c499390 profile image
mannahil huzaifa

" uk49stoday.com Absolutely love how quick and accurate the results are on uk49stoday.com! The layout is super clean, and the predictions section has been surprisingly helpful. Keep up the great work — this is my go-to site for everything UK49s!

Collapse
 
mannahil_huzaifa_5c499390 profile image
mannahil huzaifa

I recently came across UK49s Today, and I have to say, it’s uk49stoday.com/ one of the best resources out there for UK49s lottery enthusiasts. The site provides real-time results, smart predictions, and helpful tips that really give you an edge. What I love most is how consistently it’s updated and how easy it is to navigate.