How can i set duration for "ArrayList" which shuffles after few seconds in a loop? The code below shuffle text after every page refresh.
// For full API documentation, including code examples, visit https://wix.to/94BuAAs $w.onReady(function () { });
const ArrayList = [ 'Live', 'Work', 'Play', ];
$w.onReady(function(){ const randomIndex = Math.floor(Math.random() * (ArrayList.length)); $w('#text33').text = ArrayList[randomIndex];
return ArrayList; });
Thank you!
top of page
Important forum update
This forum is migrating to one unified Wix community forum starting July 26th, and will be read-only during the process.
Wishlist Page is the official platform for requesting new features. You can vote, comment, and track the status of the requested features.
bottom of page
Try:
const ArrayList = [ 'Live', 'Work', 'Play',]; const interval = 3000;// milliseconds setInteraval(() => shuffleArray , interval); function shuffleArray() { for (let i = array.length - 1; i > 0; i--) { const random = Math.floor(Math.random() * (i + 1)); [ArrayList[i], ArrayList[random] = [ArrayList[random], ArrayList[i]]; } }