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 trialZachary Smith
Full Stack JavaScript Techdegree Graduate 16,616 PointsMy solution for "How many seconds have I been alive?"
Hi all, figured I would share my solution as suggested by the video.
Any thoughts on how to make this more efficient? I'm still extremely new. Also is there a way to embed this code into a message without doing 3 backticks on every line? Thanks!
2 Answers
Victor Mercier
14,667 PointsHi, with the knowledge you know, you cannot really make this solution better but you will soon learn more advanced topics that will make you able to improve it!
Steven Parker
231,153 PointsIt's only a tiny improvement, but you can use expressions inside interpolation tokens to avoid creating variables that aren't otherwise needed:
console.log(`I've been alive for more than ${secondsPerYear * yearsAlive} seconds!`);
And the 3 backticks can be used on a line by themselves before and after the code instead of on every line (as I did above). For more info, see this video on Markdown formatting.