I'm wokring with some assignements i got in school and I'm very new to coding. My goal is to present name FirstName & LastName of all all these variables in a span with an onclick. But the issue is that the loop seems to return [object Object] instead of the actual values of each new Person. It currently looks like this:
(I'm only to use pure Javascript without any help of Jquery or the use of Json with this code)
function Person(firstName, lastName, adress, phone) {
this.FirstName = firstName;
this.LastName = lastName;
this.Adress = adress;
this.Phone = phone;
}
var p1 = new Person("Anton", "Andersson","Nonstans", "1324565451");
var p2 = new Person("Felix", "Berge", "Krillan", "1234567889");
var p3 = new Person("Oscar", "Rells", "Essingen", "1234567888");
var p4 = new Person("Theodor", "Johansson", "Hemma", "1234567810");
var p5 = new Person("Jacob", "Lagstrom", "Ensam 78", "1234567892");
var Persons = [p1, p2, p3, p4, p5];
for (var i = 0; i < Persons.length; i++) {
var personList = document.getElementById("personLista")
personList.textContent += Persons [i] + ", ";
}