JSFiddle - React, Tailwind, and code Playground

by oysteinmoseng

JavaScript

console.clear();

const arr = [];

function x(el) {
    let i = arr.length;
    while (i-- && arr[i].time > el.time) { /* */ }
    arr.splice(i + 1, 0, el);
}

x({ time: 9, aha: true })
console.log(JSON.stringify(arr));