Easy there, pal!
To access the Introduction to programming challenges in the JavaScript programming, you need to sign up and subscribe first.
Your task is to develop a fitness calculator for Muffin. Here is a functional specification written by his very pawn:
Meow! I need to shape up by CatFashionExpo2018. And I need my own special fitness calculator for that.
I enter the amount of food I ate in grams and the number of hours that I slept last night, and it creates a training program from the following exercises:
- jumps onto the bookcase (strength training for hind legs)
- pull-ups on the master’s hanging coat (strength training for front legs),
- running in circles around the room (stamina improvement).
Here is the calculator’s algorithm:
We store the weight of the food in thefoodInGramsvariable. The sleep time is stored in thesleepInHoursvariable. We will be saving integers to both variables. I will get 3 jumps for every 10 grams of the food I ate. For example: need to make 15 jumps for eating 50 grams of food. We’ll store the jumps count in thejumpsvariable. For every hour of sleep, I get 2 pull-ups. For example: I slept for 5 hours and now have to do 10 pull-ups. We’ll store the pull-ups count in thepullsvariable. Each jump comes with a round of running, each pull-up, a half of a round. For example: you get 20 rounds around the room for 15 jumps and 10 pull-ups. We’ll store the runs count in therunsvariable.It would be better to log the values of variables in the console.
Calculate the number of circles, if the food weight is 300 grams and the sleep time is 10 hours.
// How many 10-gram parts there are in the food
300 / 10 = 30;
// Number of jumps
// For each 10 grams, 3 jumps are added
30 * 3 = 90
// Number of pull-ups
// For each hour of sleep, 2 pull-ups are added
10 * 2 = 20
// Number of circles for jumps
// For each jump - one circle to run
90 * 1 = 90
// Number of circles for pull-ups
// For each pull-up — half a circle
20 / 2 = 10
// Total number of circles
90 + 10 = 100This is an unusual task. The boss will be testing our program by passing different values to input variables and checking the recommendations shown by the program. Once the tests have been successfully passed, the task will be completed.
To invite Muffin to test the program, click the Hey boss, here’s your program! button in the console.
You’ve gone to a different page
Click inside the mini-browser to shift the focus onto this window.
To access the Introduction to programming challenges in the JavaScript programming, you need to sign up and subscribe first.
Have you forgotten your password or lost access to your profile? Enter your email connected to your profile and we will send you a link to restore access.
Forgot to connect your email to the profile? Email us and we’ll help.