Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialVivian Oyemike
6,586 PointsHi, Please I need help with the following. Thanks
Complete the code below to create variables scoped to the secondsWorked function:
function secondsWorked(hours); totalTime; minutesInHour = 60; minutesInSecond = 60; totalTime = hours * minutesInHour * minutesInSecond; } console.log( secondsWorked(40) );
2 Answers
KRIS NIKOLAISEN
54,971 PointsYou'll make decisions on how you declare based on whether the value will change. This only applies to totalTime. Converting between seconds, minutes and hours involves constants. So
function secondsWorked(hours);
let totalTime;
const minutesInHour = 60;
const minutesInSecond = 60;
totalTime = hours * minutesInHour * minutesInSecond;
}
console.log( secondsWorked(40) );
As an aside the constant to convert seconds to minutes should correctly be named secondsInMinute
Wonderful Gapara
3,163 Pointsthank you
Vivian Oyemike
6,586 PointsVivian Oyemike
6,586 PointsThank you for your swift response. I did try to figure it out.