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.

JavaScript JavaScript Loops, Arrays and Objects Tracking Data Using Objects Accessing Object Properties

Tadjiev Codes
Tadjiev Codes
9,623 Points

Only objects word shown once reloaded. What could possibly be the problem?

Only objects word shown once reloaded. What could possibly be the problem?

var person = { name : 'Sarah', country : 'US', age : 35, treehouseStudent : true, skills : ['JavaScript', 'HTML', 'CSS'] };

function print(message) { var div = document.getElementById('output'); div.innerHTML = message; }

var message = '<p> Hello. My name is' + peson.name + '</p>'; message += '<p> I live in the' + person.country + '</p>'; person.name = "Rainbow dash"; message += '<p> But I wish my name was' + person.name + '</p>'; person.age +=1 ; message += '<p> My age is now ' + person.age + '</p>'; message += '<p> I have ' + person.skills.length + 'skills:'; message += person.skills.join + (', ') + </p>;


2 Answers

Richard Verbraak
Richard Verbraak
7,726 Points

You have a spelling error in the first line of your message variable. It says peson.name instead of person ;) I have run the code again and noticed you had an out of place closing </p> tag at the end of the message. Meaning, you didn't add the tag within the ' ' quotes.

The last line should read as follows:

message += "<p>I have " + person.skills.length + " skills: " + person.skills.join(", "); + "</p>"

I found three issues

1) A typo for person.name here

var message = '<p> Hello. My name is' + peson.name 

2) Use of parentheses for the join method

message += person.skills.join(', ') + '</p>';

3) Same line quotes around the closing paragraph tag

message += person.skills.join(', ') + '</p>';