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

JavaScript

Why doesn't this work?

function getDate() {
  var theDate = new Date();
  return theDate;
}

document.write( "<h1> getDate() </h1>");

1 Answer

Christian,

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

Wow, beat me for 25 seconds with the right answer ;P. Charles Kenney

Haha sorry man!

Thanks. Now I feel silly for how simple that was. Lol.

Christian Erickson you'd be surprised how often that silly stuff happens to most of us xD

^^