Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function workout(input) {
- let days = Number(input[0]);
- let kilometers = Number(input[1]);
- let totalKilometers = kilometers;
- for (let i = 2; i < days + 2; i++) {
- let percentage = Number(input[i]);
- kilometers *= (100.0 + percentage) / 100;
- totalKilometers += kilometers;
- }
- if (totalKilometers < 1000) {
- console.log(`Sorry Mrs.Ivanova, you need to run ${1000 - Math.floor(totalKilometers)} more kilometers`);
- } else {
- console.log(`You've done a great job running ${Math.ceil(totalKilometers) - 1000} more kilometers!`);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement