https://russian-dima.wixsite.com/my-site-13/blank-2
Generated out of the following example with some edits…
Working code on the page…
const allUrls = [
'https://www.google.com',
'https://www.facebook.com',
'https://www.cnn.com',
'https://www.abc.com',
'https://www.youtube.com'
];
$w.onReady(function(){
$w('#button1').onClick(()=>{
const randomNumber = Math.floor(Math.random() * allUrls.length);
console.log('Random-Number: ', randomNumber+1)
$w('#button2').label = String(allUrls[randomNumber]);
$w('#button2').link = String(allUrls[randomNumber]);
});
$w('#button2').onClick(()=>{
//.....what ever....
});
});
All you need to recreate this function is a blank Wix-Page inside your Wix-Editor and 2 buttons on stage (button1 & button2) and of course the shown code.
GOOD LUCK & HAPPY CODING !