Help with jQuery. Can't output text to a web page [Solved]

Hi clever people of FCC,
I have here a very simple array, which I want to .text() on the page, but only get
[object Object], [object Object], [object Object]

What am I doing wrong? here is my project: http://codepen.io/MrsColombo/pen/WxPXOm?editors=0010

Thank you so much in advance!

Julia

Hey, you can’t .text() an object. You can loop through the array and use dot notation (or bracket notation) to acces properties of the object:

var text = "";

arr.forEach(function(el){
  text += el.firstName + " ";
  text += el.lastName;
  text += "<br />";
});

$('.output').html(text);

Or if you just want to see al the properties, use this forEach loop:

arr.forEach(function(el){
  text += JSON.stringify(el);
});

But if it is only for checking, you might want to use the console.

Hi Ben,

thanks a lot. It works!