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 trialClare Yeadon
5,553 PointsCode not working
Hello, when I run the code below the console is only showing "There are ${SecsPerDay} seconds in a day." Also, I am trying to learn how to use Markdown.
const secsPerMin = 60;
const MinPerHour = 60;
const HourPerDay = 24;
const DayPerWeek = 7;
const WeekPerYear = 52;
const SecsPerDay = secsPerMin * MinPerHour * HourPerDay;
console.log('There are ${SecsPerDay} seconds in a day.');
5 Answers
connor ingold
5,382 PointsUse backticks instead of quotation marks ' '
Clare Yeadon
5,553 PointsThank you!
Craig Britton
Full Stack JavaScript Techdegree Student 2,690 Pointsconst secsPerMin = 60;
const minsPerHour = 60;
const hoursPerDay = 24;
const daysPerWeek = 7;
const weeksPerYear = 52;
const secsPerday = secsPerMin * minsPerHour * hoursPerDay;
const hoursPerWeek = hoursPerDay * daysPerWeek;
const minsInYear = minsPerHour * hoursPerDay * weeksPerYear;
console.log(`There are ${secsPerday} seconds in a day.`);
console.log(`There are ${hoursPerWeek} hours in a week.`);
console.log(`There are ${minsInYear} minutes in a year.`);
const yearsAlive = 28 * weeksPerYear;
const secsAlive = secsPerday * daysPerWeek * yearsAlive;
console.log(`I've been alive for more than ${secsAlive} seconds!`);
Chiranjeev Prajapat
Full Stack JavaScript Techdegree Student 4,257 PointsMy solution of the SecondsAlive Challenge
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 secsPerYear = secsPerMin * minsPerHour * hoursPerDay * 365; const secondsAlive = yearsAlive * secsPerYear;
console.log(I've been alive for more than ${secondsAlive} seconds!
);
connor ingold
5,382 PointsMight be of out the scope of this but you could also define your variables like so:
const secsPerMin = 60,
MinPerHour = 60,
HourPerDay = 24,
DayPerWeek = 7,
WeekPerYear = 52;
const SecsPerDay = secsPerMin * MinPerHour * HourPerDay;
console.log(`There are ${SecsPerDay} seconds in a day.`);