Easy there, pal!
To access the Loops challenges in the JavaScript programming, you need to sign up and subscribe first.
The time has come to create the third own program, which will help Muffin properly stock up on protein for any period, for example, for 15 or 25 days.
The peculiarity of Muffin’s diet is that the amount of protein on even and odd days is different. Anyway, here is the technical assignment written by Muffin’s paw:
Meow! The program should calculate how much protein I need to drink for the entire training period.
On even days, I drink
200grams. On odd days100grams.The number of days is stored in variable
days, the amount of protein to consume on an even day in variableevenDayAmount, protein on an odd day in variableoddDayAmount, and the result must be written into variabletotal, which is already defined.
In this program, it is convenient to use a loop in which the amount of protein will accumulate. Note that in the task, you work with days, therefore days must be counted from 1, and not from 0.
In order for the task to be solved correctly, we must determine how many even and odd days there are in a period. Use the % operator to do this (remainder in division).
To call Muffin to check the program, press the Hey boss, here’s your program! button located 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 Loops 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.