+
-
-
-
+
+
+ // Calculate the time difference between the start and end dates in milliseconds
+ const timeDiffMs = endDate.getTime() - startDate.getTime();
+
+ // Calculate the distance traveled based on speed and time difference
+ const distance = speedPerMs * timeDiffMs;
+
+ return distance;
+ }
+
+ function calculateCalories(startDate, endDate, power) {
+ // Calculate the time difference between the start and end dates in seconds
+ const timeDiffSec = (endDate.getTime() - startDate.getTime()) / 1000;
+
+ // Calculate the energy(joules) expended based on power and time difference
+ const energy = powerPerSec * timeDiffSec;
+
+ //Convert joules to calories
+ return energy * 0.238902957619;
+ }
+
+