curriculum/challenges/english/blocks/daily-coding-challenges-javascript/694596b0585c11170ac7c7fa.md
Given the number of Calories burned during a workout, and the number of watt-hours used by your electronic devices during that workout, determine which one used more energy.
To compare them, convert both values to joules using the following conversions:
Return:
"Workout" if the workout used more energy."Devices" if the device used more energy."Equal" if both used the same amount of energy.compareEnergy(250, 50) should return "Workout".
assert.equal(compareEnergy(250, 50), "Workout");
compareEnergy(100, 200) should return "Devices".
assert.equal(compareEnergy(100, 200), "Devices");
compareEnergy(450, 523) should return "Equal".
assert.equal(compareEnergy(450, 523), "Equal");
compareEnergy(300, 75) should return "Workout".
assert.equal(compareEnergy(300, 75), "Workout");
compareEnergy(200, 250) should return "Devices".
assert.equal(compareEnergy(200, 250), "Devices");
compareEnergy(900, 1046) should return "Equal".
assert.equal(compareEnergy(900, 1046), "Equal");
function compareEnergy(caloriesBurned, wattHoursUsed) {
return caloriesBurned;
}
function compareEnergy(caloriesBurned, wattHoursUsed) {
const workoutEnergy = caloriesBurned * 4184;
const deviceEnergy = wattHoursUsed * 3600;
console.log(workoutEnergy);
console.log(deviceEnergy);
if (workoutEnergy > deviceEnergy) return "Workout";
if (deviceEnergy > workoutEnergy) return "Devices";
return "Equal";
}