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!
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
Jamie ReardonTreehouse Project Reviewer
I approached this with only adding one new variable. Is that good or bad?
I did this a lot differently to the rest of you guys. I didn't even think about storing other values into other variables to calculate this. I just went straight in to a new variable to calculate the values in the other variables that Dave created in the video. I am not sure if this is a bad thing or not? I mean, I can only see it being a bad thing if this program were to be future-proof, because it lacks other ways to get information due to other variables that don't exist. However, what do you guys think?
var secondsPerMin = 60; var minsPerHour = 60; var hoursPerDay = 24; var daysPerWeek = 7; var weeksPerYear = 52; var secondsPerDay = secondsPerMin * minsPerHour * hoursPerDay; document.write('<p>There are ' + secondsPerDay + ' seconds in a day</p>'); var yearsAlive = 28; var secondsPerYearsAlive = secondsPerDay * daysPerWeek * weeksPerYear * yearsAlive; document.write("<p>I've been alive for more than " + secondsPerYearsAlive + " seconds</p>");
Victor Warner1,882 Points
I did the math wrong dviding first and incuding secondsperMin and minsPerHour. This answer helped me correct it. thank You.