I used a script to read my Firestore database and add the data to a table on my page.
//On button click show detailed transactions by truck
$(".view").click(function() {
$("#transTable > tbody").empty();
var truck = document.getElementById("reg").value
$("#truckreg").text("Registration: " + truck);
firebase.firestore().collection('Vehicle').doc(truck).collection('Refuels').orderBy('Date')
.onSnapshot(function(snapshot) {
snapshot.docChanges().forEach(function(change) {
trans = change.doc.data()
$('#transTable tbody').append($("<tr data-efficiency='" + trans.Efficiency + "'><td>" + trans.Date + "</td><td>" + trans.Odometer + "</td><td>" + trans.Volume + "</td><td>" + trans.Price + "</td><td class= 'efficiency'>" + trans.Efficiency + "</td></tr>"));
});
});
findLowestEfficiency();
});
My HTML table displays all the information without any issues.
Now I'd like to add a conditional format on the last / Efficiency column in my table.
When trying the following code:
var lowestEfficiency = null;
function findLowestEfficiency() {
console.log("document.querySelector('#transTable tbody').children")
console.log(document.querySelector("#transTable tbody").children)
console.log("Array.from(document.querySelector('#transTable tbody').children);")
var rows = Array.from(document.querySelector("#transTable tbody").children);
console.log(rows)
rows.forEach(function(ele) {
var res = ele.getAttribute('data-efficiency');
console.log(res)
if (lowestEfficiency == null || res < lowestEfficiency) {
lowestEfficiency = res;
}
});
document.querySelector("#transTable > tbody tr[data-efficiency=\"" + lowestEfficiency + "\"] .efficiency").classList.add("lowest");
console.log("Class added")
}
The HTMLCollection does not get correctly converted to an array as seen by the following screenshot of the console log:

