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
Christian Erickson
2,299 PointsWhy doesn't this work?
function getDate() {
var theDate = new Date();
return theDate;
}
document.write( "<h1> getDate() </h1>");
1 Answer
Charles Kenney
15,604 PointsChristian,
You have encapsulated your call to getDate() in a string, so it will be treated as characters in a string. You simply need to concatenate the <h1> tags and the result of the getDate().
Like this:
function getDate() {
var theDate = new Date();
return theDate;
}
document.write( "<h1>" + getDate() + "</h1>");
Hope this helps, Charles
Bruno Navarrete
Full Stack JavaScript Techdegree Graduate 22,246 PointsBruno Navarrete
Full Stack JavaScript Techdegree Graduate 22,246 PointsWow, beat me for 25 seconds with the right answer ;P. Charles Kenney
Charles Kenney
15,604 PointsCharles Kenney
15,604 PointsHaha sorry man!
Christian Erickson
2,299 PointsChristian Erickson
2,299 PointsThanks. Now I feel silly for how simple that was. Lol.
Bruno Navarrete
Full Stack JavaScript Techdegree Graduate 22,246 PointsBruno Navarrete
Full Stack JavaScript Techdegree Graduate 22,246 PointsChristian Erickson you'd be surprised how often that silly stuff happens to most of us xD
Charles Kenney
15,604 PointsCharles Kenney
15,604 Points^^