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 trial

JavaScript Getting Started With ES2015 Defining Variables With let and const Review let and const

Vivian Oyemike
Vivian Oyemike
6,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) );

2 Answers

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

Vivian Oyemike
Vivian Oyemike
6,586 Points

Thank you for your swift response. I did try to figure it out.

thank you