Translate table in pure js
Try this in your loop to reference each cell and assign from your 2d array:
table.rows[i].cells[j].innerHTML = array[i][j];
Loop over the array instead and use document.createElement
to create rows and cells to append to the tbody
.
const tbody = document.querySelector('table > tbody');
var array = [
["a1", "b1", "c1"],
["a2", "b1", "c1"],
["a3", "b1", "c1"],
["a4", "b1", "c1"],
["a5", "b1", "c1"],
["a6", "b1", "c1"],
["a7", "b1", "c1"],
];
for (var i = 0; i < array.length; i++) {
const row = document.createElement('tr');
for (var j = 0; j < array[i].length; j++) {
const cell = document.createElement('td');
cell.textContent = array[i][j];
row.appendChild(cell);
}
tbody.appendChild(row);
}
<link href="https://getbootstrap.com/docs/4.0/dist/css/bootstrap.min.css" rel="stylesheet"/>
<table class="table table-striped" id="TabelPret">
<thead>
<tr>
<th scope="col">id</th>
<th scope="col">service</th>
<th scope="col">price(Euro)</th>
</tr>
</thead>
<tbody>
</tbody>
</table>