Easy there, pal!
To access the Loops challenges in the JavaScript programming, you need to sign up first.
You are ready to write the fourth program that the boss will test with his own paws. Here is the specification:
Meow! I’m tired of dieting and exercise, and that’s why I want to know how many more days I need to exercise to achieve my target weight for the event.
Inputs: the starting weight and the target weight.
How it works: if I exercise and diet, I lose 5% of my weight per day (you can’t really gain any weight on dry food, and my exercise sessions are harsh). I’ll keep exercising while my weight is above the target.
Count how many days I need to follow this routine and store the result in the
daysvariable.
Of course, for this program, it is more convenient to use while, since the number of iterations is unknown beforehand.
Note that every day Muffin loses 5% of his current weight. And the weight is updated every day. For example, if at first Muffin weighed 5 kg (that is 5000 grams), then the next day his weight will be 4750 grams. And on the second day, he will lose 5% of the new weight, that is, from 4750 grams. Take this into account when calculating.
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 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.