I have a table generated with Javascript that output some JSON data. Now I know I should probably not repeat myself so much but one of the element of this array needs to be wrapped in a link, and I don't know how to write a loop that output all members but the also member with some styling. Is there a way to do this in a loop, while keeping the format of output as this code gives? The table head part is already taken care of, the tbody is where I have problem: As you the last element didn't fit in a loop exactly. referring to this problem where I had it in a loop.
for (let j= 0; j< filtered.length; j++){
var row = table.insertRow(1);
row.classList.add("headRow")
var cell0 = row.insertCell(0);
cell0.innerHTML = filtered[j].Carat;
var cell1 = row.insertCell(1);
cell1.innerHTML = filtered[j].Color;
var cell2 = row.insertCell(2);
cell2.innerHTML = filtered[j].Shape;
var cell3 = row.insertCell(3);
cell3.innerHTML = filtered[j].Cut;
var cell4 = row.insertCell(4);
cell4.innerHTML = filtered[j].Symmetry;
var cell5 = row.insertCell(5);
cell5.innerHTML = filtered[j].Report;
var cell6 = row.insertCell(6);
cell6.innerHTML = filtered[j].Clarity;
var cell7 = row.insertCell(7);
cell7.innerHTML = filtered[j].Polish;
var cell8 = row.insertCell(8);
cell8.innerHTML = '<a href="' + filtered[j].link_view + '"> View</a>' ;
}