Hi, I'm making a random slider with Javascript programming language.
I have stored the slider information in the js array.
I can display slider shapes randomly.
However, when the system selects a random index from the array, there are times when it can select the same index at least two times in a row.
Accordingly, the slider is shown in the same way, with a minimum of 2 times.
I need a code to redeem it.
I have stored the slider information in the js array.
I can display slider shapes randomly.
However, when the system selects a random index from the array, there are times when it can select the same index at least two times in a row.
Accordingly, the slider is shown in the same way, with a minimum of 2 times.
I need a code to redeem it.
Code:
JavaScript:
const models = [
{
name: 'Bmw 418d',
image: 'img/bmw.jpg',
},
{
name : 'Mazda CX-3',
image : 'img/mazda.jpg',
},
{
name : 'Volvo S60',
image : 'img/volvo.jpg',
},
{
name : 'Skoda Superb',
image : 'img/skoda.jpg',
},
{
name : 'Honda Civic',
image : 'img/honda.jpg',
}
];
const countSliders = models.length;
function init(options) {
showSlider(index);
interval = setInterval(() => {
if(options.random) {
index = Math.floor(Math.random()*countSliders); //->array icerisinden random deyeri minimum 2 defe eyni olaraq secen js statement.
}
else {