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