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 trialderek hunter
3,386 Pointswas this good?
const age= 37
const secspermin = 60
const minsperhour= 60
const hoursperday= 24
const daysperweek=7
const weeksperyear=52
const daysperyear = 365
const secondsperday = secspermin * minsperhour * hoursperday;
console.log (` there are ${secondsperday} seconds in a day.`);
const yearsAlive= secspermin * minsperhour *hoursperday * daysperyear * age;
console.log (`I've been alive for more than ${yearsAlive} seconds !`);
Caleb Kemp
12,755 PointsCaleb Kemp
12,755 PointsI tested it and it produced result as intended, however, there are 2-3 things I think could potentially be improved.
-1. As a best practice, your const variables should have semicolons(;) after them. Such that
const dayperweek = 7
should look like
const dayperweek = 7;
-2. Usually it is a good idea to use coding conventions when possible. One of the conventions of Javascript is to name the variables using camel case. So, using camel case this...
const weeksperyear = 60;
would have looked like
const weeksPerYear = 60;
-3. It seemed to me, since you had already calculated and stored secondsPerDay, it might have made sense to use that in your yearsAlive calculation, but just a thought. So that
const yearsAlive= secsPerMin * minsPerHour *hoursPerDay * daysPerYear * age;
would have looked like
const yearsAlive= secondsPerDay * daysPerYear * age;
Way to keep coding