I have an array with many five users that I'm trying to display on a table in my HTML. I THINK I did a good job with my JS code (or at least I think so...lol... I'm new with coding), I just don't understand how to display this whole table content of arrays in my HTML. I tried the .innerHTML thing but it doesn't work.
Hope someone can figure it out. Thanks in advance. :S :)
let myArr = [];
function User (name, lastname, city, email) {
this.name = name;
this.lastname = lastname;
this.city = city;
this.email = email;
}
let userOne = new User('Leonardo', 'Parigini', 'Santorini', 'leoparigini@gmail.com');
let userTwo = new User('Edoardo', 'Merlini', 'Monaco', 'edomerlini@gmail.com');
let userThree = new User('Nicole', 'De Lellis', 'Milano', 'nickydelellis@gmail.com');
let userFour = new User('Jasmine', 'Scherzinger', 'Los Angeles', 'jazzylax@gmail.com');
let userFive = new User('Emily', 'Knowles', 'San Francisco', 'emilyknow@gmail.com');
myArr.push(userOne, userTwo, userThree, userFour, userFive);
console.log(myArr);
let myNewArr = [...myArr];
console.log(myNewArr);
var table = document.querySelector('#myTable')
table.innerHTML = '<tr><td>' + myNewArr + '</td></tr>'
<body class="bg-info">
<div class="container">
<h1 class="display-3">USER LIST</h1>
<table class="table table-dark table-striped" id="myTable">
<thead>
<tr>
<th scope="col" id="nome">Nome</th>
<th scope="col" id="cognome">Cognome</th>
<th scope="col" id="citta">Città</th>
<th scope="col" id="email">Email</th>
</tr>
</thead>
<tbody>
<!-- <tr id="myListHTML"> </tr>
<th scope="row"></th>
<td>Jacob</td>
<td>Thornton</td>
<td>@fat</td>
<tr>
<th sco pe="row">3</th>
<td colspan="2">Larry the Bird</td>
<td>@twitter</td>
</tr>
</tbody> -->
</table>
</div>