JSFiddle - React, Tailwind, and code Playground
JavaScript
function getRndInteger(min = 1, max = 5, step = 1) {
const range = (max - min) / step
return Math.floor(Math.random() * range) * step + min
}
const items = []
let obj = {
content: "<p></p>"
}
setInterval(() => {
const random = getRndInteger(1, 3)
obj = {
content: `<p>hello world ${random}</p>`
}
if (items.indexOf(obj.content) === -1) items.push(obj)
console.log(items)
}, 1000)