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 JavaScript Loops, Arrays and Objects Tracking Data Using Objects Accessing Object Properties

Tadjiev Codes
Tadjiev Codes
9,626 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>;

print(message);

2 Answers

Richard Verbraak
Richard Verbraak
7,739 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>';