Answer the question
In order to leave comments, you need to log in
How to shift an array by removing the first element?
I want to make some "shift" of the array so that it works like this:
there is an array:
[
{
id: 1
},
{
id: 2
}
]
setInterval(() => {
step++;
// let rand = this.cases[getRandomInt(3)]
carousel.style.right = step * 2 + "px";
// carousel.appendChild(rand);
}, time);
setInterval(() => {
this.cases.push(this.cases[getRandomInt(8)])
this.cases.shift()
}, 1000);
after that another object should be added, but the very first object (where id: 1) should be removed, creating a "shift" .
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question