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 trialAlistair Lamberth
1,874 PointsTurns out I am at least 2505600 seconds old. Sound right to you guys?
This is how I did it... I am 29 years old. What do you guys reckon?
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 = 29 *secsPerMin * minsPerHour * hoursPerDay;
console.log(I have been alive for more than ${yearsAlive} seconds
);
Mohammed Hashmi
520 PointsLol i was wondering if i did wrong! XD
Abdulsalam Jumah
3,679 Pointsyou have multiplied 29 by seconds per day so it means you have calculated the seconds in 29 days.
you can either multiply -> 29 * 365 which gives the number of days in 29 year since a year is 365 days and then multiply by secondsPerDay or just multiply all the variable made in the beginning (from secsPerMIn to weeksPerYear) and then multiply that with 29.
14 Answers
Joseph Hookham
2,493 PointsNo I think it should be around 1 billion (10 digits)
You've only multiplied by days (not years).
Use the 'secondsPerDay' that you did with Guill as a headstart.
Now you just multiply secondsPerDay X daysPerWeek X weeksPerYear X yearsAlive.
Here's mine:
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 = 33; const secsAlive = secondsPerDay * daysPerWeek * weeksPerYear * yearsAlive;
console.log (I've been alive for more than ${secsAlive} seconds!
);
ANSWER ON CONSOLE = 1,037,836,800
Austin Hinz
3,194 PointsHello,
Here is my answer for someone that is 21:
//Variables that I will be using for the calculations
const secsPerMin = 60;
const minsPerHour = 60;
const hoursPerDay = 24;
const yearsMeAlive = 21;
const daysInYear = 365;
//Below are the variables created by combining above variables with math operators
const secondsPerDay = ( secsPerMin * minsPerHour * hoursPerDay );
const secondsAlive = ( secondsPerDay * daysInYear * yearsMeAlive );
//Below is what is the console.log output
I've been alive for more than 662256000 seconds! // 662_256_000 seconds
Hope this helps someone! Happy Coding :D
-Austin
Anna Sams
4,497 PointsHere's my solution to share, including what we went over in the video! Happy coding!
const secsPerMin = 60;
const minsPerHour = 60;
const hoursPerDay = 24;
const daysPerWeek = 7;
const weeksPerYear = 52;
const secsPerDay = secsPerMin*minsPerHour*hoursPerDay;
console.log (`There are ${secsPerDay} seconds in a day`);
const yearsAlive = 27
const secsAlive = secsPerDay*daysPerWeek*weeksPerYear*yearsAlive
console.log(`I've been alive for more than ${secsAlive} seconds!`);
Donna Cretella
Front End Web Development Techdegree Student 2,577 PointsHere is the Math:
const yearsAlive = secondsPerDay * daysPerWeek * weeksPerYear;
const secsAlive = yearsAlive * 40;
console.log(I've been alive for more than ${secsAlive} seconds!.
);
Answer: I've been alive for more than 1257984000 seconds!.
Unsubscribed User
785 PointsSeconds Per Day? No Minutes or Hours:-)
Mohammed Hashmi
520 Pointsconst secsPerMin = 60; const minsPerHour= 60; const hoursPerDay = 24; const daysPerWeek = 7; const weeksPerYear = 52;
const secondsPerDay = secsPerMin * minsPerHour * hoursPerDay; const yearsAlive = X * weeksPerYear*daysPerWeek*hoursPerDay*minsPerHour*secsPerMin;
console.log(There are ${secondsPerDay} seconds in a day.
);
console.log (I have been alive for more than ${yearsAlive}
);
Hope i am helpful !
ala4
3,609 PointsHere is my work to share
const secsPerMin = 60; const minsPerHour= 60; const hoursPerDay= 24; const daysPerWeek= 7; const weeksPerYear= 52; const daysPerYear= 365; const yearsAlive = 40;
const secondsPerDay= secsPerMin * minsPerHour * hoursPerDay;
const aliveInSeconds = yearsAlive * daysPerYear * secondsPerDay;
console.log(I have been alive for more than ${aliveInSeconds} seconds
);
Happy coding :)
KENDRA WARD
5,126 PointsI'm shocked 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 yearsAlive = 36;
const secsAlive = yearsAlive * secondsPerDay;
console.log(I've been alive for more than ${secsAlive} seconds!
);
Ian Hawe
Courses Plus Student 10,579 Pointsconst secsPerDay = secsPerMin * minsPerHour * hoursPerDay; const yearsAlive = secsPerMin * minsPerHour * hoursPerDay * daysPerYear * age;
console.log(There are ${secsPerDay} seconds in a day
);
console.log(I've been alive for more than ${yearsAlive} seconds!
);
math.js:11 I've been alive for more than 883008000 seconds!
olhahelena
6,731 PointsThis is what I came up with. I used previously declared variables in this exercise.
const secsPerMin = 60; const minsPerHour = 60; const hoursPerDay = 24; const daysPerWeek = 7; const weeksPerYear = 52; const yearsAlive = 26;
const secsPerDay = secsPerMin * minsPerHour * hoursPerDay; console.log (There are ${secsPerDay} seconds in a day.);
const secsAlive = (secsPerDay * 365) * yearsAlive; console.log(I've been alive for more than ${secsAlive} seconds!);
Console: I've been alive for more than 819936000 seconds!
Happy Coding!!
Kendall McCall
8,177 PointsHere is my attempt :)
const secPerMin = 60; const minPerHour = 60; const hoursPerDay = 24; const daysPerWeek = 7; const weeksPerYear = 52;
const secondsPerDay = secPerMin * minPerHour * hoursPerDay;
console.log(There are ${secondsPerDay} seconds in a day.
);
const yearsAlive = 24;
const secsAlive = secondsPerDay * daysPerWeek * weeksPerYear * yearsAlive;
console.log(I have been alive for more than ${secsAlive} seconds!
);
Amy Tomey
12,847 PointsI've been alive for more than 1949875200 seconds. (i think I got y'all beat?) where did all that time go?
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 secondsPerYear = secondsPerDay * daysPerWeek * weeksPerYear; const yearsAlive = 62; const x = yearsAlive * secondsPerYear
console.log(I've been alive for more than ${x} seconds
)
Alex Diaz
502 Pointsconst 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 = 35;
const secondsAlive = secondsPerDay * daysPerWeek * weeksPerYear * yearsAlive;
console.log(`I've been alive for more than ${secondsAlive} seconds!`);
document.querySelector('main').innerHTML = `<h1>I've been alive for more than ${secondsAlive} seconds!</h1>`;
Here's my solution, I like also practicing writing to the main!
Heather Bjoin
11,195 PointsI think it's a great idea to practice posting these to the main! I'm borrowing that idea from now on, thank you!
Brian Hough
1,948 PointsHere's my solution! Turns out I've been alive for more than 788400000 seconds!
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 = 25;
const secsAlive = secondsPerDay * 365 * yearsAlive;
console.log(`I've been alive for more than ${secsAlive} seconds!`);
Hilary Scott
Full Stack JavaScript Techdegree Student 2,994 Pointsconst secsPerMin = 60, minsPerHour = 60, hoursPerDay = 24, daysPerWeek = 7, weeksPerYear = 52, secondsPerDay = secsPerMin * minsPerHour *hoursPerDay;
console.log(There are ${secondsPerDay} seconds in a day
);
const yearsAlive = 30, secondsAlive = secondsPerDay * daysPerWeek * weeksPerYear * yearsAlive;
console.log(I've been alive for more then ${secondsAlive} seconds
);
Unsubscribed User
785 PointsI am 1415232000 seconds old.
ALEXANDER MARININ
Full Stack JavaScript Techdegree Student 5,276 PointsALEXANDER MARININ
Full Stack JavaScript Techdegree Student 5,276 PointsYou only got 29 days result not years.(you need the whole sum of seconds in one year * 29)