JSFiddle - React, Tailwind, and code Playground

by electronoob

HTML

<div id=q></div>

JavaScript

// queue cue
let c = [];
let id = 0;
c.push({
	id:id++,
  start: Date.now(),
  end:  Date.now() + 500,
  type: "construction",
  item: 3
});
c.push({
	id:id++,
  start: Date.now(),
  end:  Date.now() + 1000,
  type: "construction",
  item: 3
});
c.push({
	id:id++,
  start: Date.now(),
  end:  Date.now() + 1500,
  type: "construction",
  item: 3
});
c.push({
	id:id++,
  start: Date.now(),
  end:  Date.now() + 1800,
  type: "construction",
  item: 3
});

setInterval(()=>{
	var ts = Date.now();
	c.forEach((item,index)=>{
  	console.log(item, ts);
    if(ts>item.end) {
    	c=c.slice(index);
    }
  })
  console.log(0);
}, 1000);