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 trialch.ienwie suh
Courses Plus Student 1,143 PointsThis is my solution. Don't know if i got it right?
const secsPerMin = 60; const minsPerHour = 60; const hoursPerDay = 24; const daysPerWeek = 7; const weeksPeryear = 52;
const secondsPerDay = secsPerMin * minsPerHour * hoursPerDay;
console.log(There are ${secondsPerDay} seconds in a day.
);
const daysPerYear = 365; const yearsAlive = 35;
const secondsAlive = secondsPerDay * daysPerYear * yearsAlive;
console.log(I have been alive for more than ${secondsAlive} seconds!
);
8 Answers
Steven Parker
231,269 PointsI think the idea was to complete the calculation using only the variables created already in the video.
Hint: you defined "daysPerWeek " and "weeksPeryear" but have not used them yet.
Molly Zalman
Full Stack JavaScript Techdegree Student 12,522 Pointsconst secsPerMin = 60; const minsPerHour = 60; const hoursPerDay = 24; const daysPerWeek = 7; const weeksPerYear = 52;
const yearsAlive = 23;
const secondsAlive = secsPerMin * minsPerHour * hoursPerDay * daysPerWeek * weeksPerYear * yearsAlive;
console.log(I've been alive for more than ${secondsAlive} seconds!
);
This is what I got, and it isn't exactly correct but I'm just happy I made legitimate code!
shuai zhao
2,122 Pointsconst secsPerMin = 60; const minsPerHr = 60; const hrsPerDay = 24; const daysPerWeek = 7; const weeksPerYear = 52;
const secondsPerDay = secsPerMin * minsPerHr * hrsPerDay;
console.log(There are ${secondsPerDay} seconds in a day.
);
const yearsAlive = secsPerMin * minsPerHr * hrsPerDay * daysPerWeek * weeksPerYear * 31;
console.log(Ive been alive for more than [974937600] seconds!
);
Rachael Carter
3,417 PointsWe already defined 'secondsPerDay' earlier in the video, so I used that in my calculation:
const yearsAlive = 34; const secondsAlive = secondsPerDay * daysPerWeek * weeksPerYear * yearsAlive;
console.log(I've been alive for more than ${secondsAlive} seconds!
);
I've been alive for more than 1069286400 seconds!
T. Gontarek
7,030 Pointsconst secondsPerDay = secsPerMin * minsPerHour * hoursPerDay;
console.log(`There are ${secondsPerDay} seconds in a day.`);
const yearsAlive = 34;
const secondsAlive = secondsPerDay * yearsAlive;
console.log(`I've been alive for more than ${secondsAlive} seconds.`);
"I've been alive for more than 2937600 seconds."
JOSHUA ESTEP
523 PointsThis is what I got for this.
const secsPerMin = 60; const minsPerHour = 60; const hoursPerDay = 24; const daysPerWeek = 7; const weeksPerYear = 52;
const secondsPerDay = secsPerMin * minsPerHour * hoursPerDay;
console.log(there are ${secondsPerDay} seconds in a day.
);
const yearsAlive = 36;
const secondsAlive = secondsPerDay * yearsAlive * daysPerWeek * weeksPerYear;
console.log(I've been alive for more then ${secondsAlive} seconds.
);
"there are 86400 seconds in a day." "I've been alive for more then 1132185600 seconds."
Pedro Oliveira
2,902 Pointsconst secsPerMinute = 60;
const minPerHour = 60;
const hourPerDay= 24;
const dayPerWeek = 7;
const weekPerYear = 52;
const secsPerDay = secsPerMinute*minPerHour*hourPerDay;
console.log (`There are ${secsPerDay} seconds per day`);
const yearsAlive = 35;
console.log (`I've been alive for ${yearsAlive*secsPerDay*365} seconds.`);
I went a different way and did the calculation in the template literal. Worked like a charm.
Brandon Jones-Harris
6,713 Pointsconst secsPerMin = 60; const minsPerHour = 60; const hoursPerDay = 24; const daysPerWeek = 7; const weeksPerYear = 52; const yearsAlive = 36;
const secondsPerDay = secsPerMin * minsPerHour * hoursPerDay;
console.log(There are ${secondsPerDay} secoonds in a day.
);
const secondsAlive = secsPerMin * minsPerHour * hoursPerDay * daysPerWeek * weeksPerYear* yearsAlive;
console.log(I've been alive for more than ${secondsAlive} seconds!
)
Brian Bochicchio
19,978 PointsBrian Bochicchio
19,978 PointsGlad you pointed this out. I looked right past them. I also got different results with my idea vs the variables in the file.
If you ask 99% of everyone they will say there are 365 days in a non-leap year. So I rolled with that.
Using the variables there are 364 days in the year.
const secondsAlive = (secondsPerDay * (daysPerWeek * weeksPerYear)) * yearsAlive;
I know we aren't looking for 100% precision in the project. But I thought it was novel and share worthy.