JavaScript Functions Exercise

Henna Singh
2 min readMar 28, 2022

#BuildTogether Day 50/100

Today has been a busy day work-wise but hey I finished 50 days of code without missing a single day… 💃🏻

It was a great learning journey and I am happy I started this. Although I am super tired at this moment but very content with the discipline and commitment 😍

Today I did another sample exercise code using Arrow Functions and Function expressions.

Exercise 01

Sleep Debt Calculator

Did you know that giraffes sleep 4.6 hours a day? We humans need more than that. If we don’t sleep enough, we accumulate sleep debt. In this project, I have created a sleep debt calculator that will calculate if I am getting enough sleep each week.

The program will determine the actual and ideal hours of sleep for each night of the last week.

Finally, it will calculate, in hours, how far I am from my weekly sleep goal.

Steps:

  1. To determine sleep for each day
  2. To calculate the sleep in a week
  3. Ideal Sleep hours are 7–8 hours
  4. Calculate sleep debt by comparing actual and ideal hours

Challenge: Ideal sleep hours can vary from person to person. Modify the function to include that.

Tomorrow I will work on the scope. Until then Happy Coding ❤

PS: If you fancy reading my 100 Days of progress, feel free to drop by ;)

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Henna Singh
Henna Singh

Written by Henna Singh

Technical Speaker and an aspiring writer with avid addiction to gadgets, meet-up groups, and paper crafts. Currently doing Full Stack Diploma at Code Institute

No responses yet

Write a response