Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
Vivian Oyemike6,586 Points
Hi, 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) );
You'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