Changeset - 58e96cb98d3a
[Not reviewed]
0 1 0
x - 15 months ago 2024-01-05 01:43:20
xbr@c3l.lu
feat: add lowestDate
1 file changed with 17 insertions and 1 deletions:
0 comments (0 inline, 0 general)
frontend/script.js
Show inline comments
 
@@ -18,13 +18,29 @@ function generateTable(data) {
 
        date.appendChild(dateText);
 
        row.appendChild(date);
 

	
 
        tableBody.appendChild(row);
 
    }
 

	
 
    const table = document.createElement("table");
 
    table.classList.add("logs__table");
 
    table.appendChild(tableBody);
 
    document.getElementById("logs").appendChild(table);
 
}
 

	
 
fetch("data.json").then(res => res.json()).then(data => generateTable(data.incidents));
 
\ No newline at end of file
 
function setLowestDate(data) {
 
    console.log(data);
 
    const lowestDate = data.reduce((minNum, expiredEntry) => {
 
        return Math.min(expiredEntry.date, minNum)
 
    }, Infinity);
 

	
 
    console.log(lowestDate);
 

	
 
    document.getElementById("time__tls").innerHTML = lowestDate;
 
}
 

	
 
fetch("data.json")
 
    .then(res => res.json())
 
    .then(data => {
 
        generateTable(data.incidents);
 
        setLowestDate(data.incidents);
 
    });
 
\ No newline at end of file
0 comments (0 inline, 0 general)