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

George Nono
George Nono
11,256 Points

What am I doing wrong?

Hi

I don't know what I'm doing wrong here, please help thanks!

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

function print(message) {
  var div = document.getElementById('output');
  div.innerHTML = message;
}
var message = '<p>Hello my name is ' + person.name + '</p>';

print(message);

//Fixed Code Presentation

4 Answers

George Nono
George Nono
11,256 Points

I'm sorry it was there I deleted it, I just put the age back and it's still not working. What is my HTML supposed to look like?

I have this :

<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> </head> <body>

<div id="innerHTML">

</div> <script src="scripts.js"></script>

</body> </html>

Looks like you're missing an integer for your age property. You can't just leave it blank.

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

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

var message = 'Hello my name is ' + person.name;

print(message);

If you're doing this on a notepad and you wanna see it print out. Make sure you have a div tag with an "output" id and link to your js file.

or do this:

<!DOCTYPE html> <html> <head> </head> <body> <div id="output"></div>

    <script script language="javascript" type="text/javascript">
    var person = {
        name: 'Sarah',
        country: 'US',
        age: 11,
        treehouseStudent: true,
        skills: ['JavaScript', 'HTML', 'CSS']
        }

    function print(message) {
        var div = document.getElementById('output');
        div.innerHTML = message;
    }
    var message = '<p>Hello my name is ' + person.name + '</p>';

    print(message);

</script>

</body>

</html>