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 JavaScript Numbers Working with Numbers Create a Program with Math

Tural Rzazade
Tural Rzazade
3,750 Points

MyCode

const secsPerMin = 60;
const minsPerHour = 60;
const hoursPerDay = 24;

//const daysPerWeek = 7;
//const weeksPerYear = 52;
//
//secondsPerDay = secsPerMin * minsPerHour * hoursPerDay;
//
//console.log(`There are ${secondsPerDay} seconds in a day.`)

const yearsAlive = 24;
const daysPerYear = 365;
const secsAlive = secsPerMin * minsPerHour * hoursPerDay * daysPerYear;


console.log(`I've been alive for more than ${secsAlive} seconds!`);
jessicakincaid
jessicakincaid
21,782 Points

Do you have a question? Are you receiving an error?

5 Answers

Steven Parker
Steven Parker
229,005 Points

I'm guessing there's no question or error here, but this is just a response to the instructor's suggestion in the video of "when you're done, why don't you share your solution with other Treehouse students?"   :see_no_evil:

josephweiss2
josephweiss2
6,982 Points

Nicely done!!! Go further with your excellent coding!!

Tural Rzazade
Tural Rzazade
3,750 Points

Thank you guys! :) Everything is fine! I know it seems a little strange to post your code by using "Get help" button, but as you guessed I did it according to Guil's suggestion. 👻

Luis Bautista
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Luis Bautista
UX Design Techdegree Graduate 21,498 Points

Here is my solution, I left the previous code in place so I could use the secondsPerDay variable and shorten the math a bit.

const secPerMin = 60;
const minsPerHour = 60;
const hoursPerDay = 24;
const daysPerWeek = 7;
const weeksPerYear = 52;

const secondsPerDay = secPerMin * minsPerHour * hoursPerDay;

console.log(`There are ${secondsPerDay} seconds in a day.`);

const yearsAlive = 44;
const daysPerYear = 365;

const secondsAlive = secondsPerDay * daysPerYear * yearsAlive;

console.log(`I've been alive for more than ${secondsAlive} seconds!`) ```