Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
Error providing variable stored within var player to the .write() method
My code as posted works whenever I run a local version of it from WebStorm. Can anyone tell me why TeamTreehouse's unit tests are returning a failure for my implementation? To me it seems as if I have in fact provided the necessary arguments to the write() method being called on the document object. Is this concatenation bad form in JS?
var player = 'Jasmine'; document.write('<h1>' + player + '</h1>');
Your code is technically fine, but challenges tend to be very strict. You are not supposed to do anything more than the exact thing the challenge asks for.
The challenge only asks for you to write the name of the player to the page, you write the name wrapped in
h1 tags. That is enough of a difference to break the challenge checker. If you remove those tags like this:
var player = 'Jasmine'; document.write(player);
Then your code will pass. And this concept of doing exactly what is specified in the instructions and nothing more holds true for most of the challenges on Treehouse. As the challenge checker is quite inflexible. This is especially true when it comes to strings, where even a difference in the spacing will often cause your code to be rejected.