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

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>