Pavel_16,
рекорды с сортировкой
<!DOCTYPE html>
<html>
<head>
<title>Untitled</title>
<meta charset="utf-8">
<style type="text/css">
table{
border: 1px solid #000000;
border-collapse: collapse;
}
td{
border: 1px solid #000000;
}
</style>
<script>
document.addEventListener( "DOMContentLoaded" , function() {
if (localStorage.getItem("users") === null) {
localStorage.setItem("users", JSON.stringify([]));
}
let users = JSON.parse(localStorage.getItem("users"));
let userName = localStorage.getItem("userName");
let time = localStorage.getItem("time");
if(time) {
users.push({userName, time});
localStorage.setItem("users", JSON.stringify(users));
localStorage.removeItem('time');
}
let html = '';
users.sort((a, b) => {
if(!a.time||!b.time) return -1;
a = a.time.split(':');
a = a[0]*100 + a[1] * 1;
b = b.time.split(':');
b = b[0]*100 + b[1] * 1;
return a - b
})
for (const {userName, time} of users) html +=
`<tr>
<td>${userName}</td>
<td>${time}</td>
</tr>`;
document.querySelector('table tbody').innerHTML = html;
});
</script>
</head>
<body>
<table>
<thead><tr>
<td>имя</td>
<td>время</td>
</tr>
</thead>
<tbody></tbody>
</table>
</body>
</html>