Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function runningInThePark(input) {
- let totalMinutes = 0, totalDistance = 0, totalCalories = 0;
- let n = Number(input[0]);
- for (let i = 1; i < n * 3; i += 3) {
- let dayMinutes = Number(input[i]);
- let dayDistance = Number(input[i + 1]);
- let distanceUnit = input[i + 2];
- if (distanceUnit == "m")
- dayDistance *= 0.001;
- totalMinutes += dayMinutes;
- totalDistance += dayDistance;
- totalCalories += dayMinutes * 400 / 20;
- }
- console.log(`He ran ${totalDistance.toFixed(2)}km for ${totalMinutes} minutes and burned ${totalCalories} calories.`);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement