Button that redirects to a random link

I am trying to use the developer mode to code a button that redirects to one of 6 links randomly

Here is the code I have. I copied it from a website and made some changes, I am not a programmer so pls help

export function button1_click(entry) {

    var links = new Array();
        links[0] = "https://www.google.com";
        links[1] = "https://www.amazon.com";
        links[2] = "https://www.apple.com";
        links[3] = "https://www.reddit.com";
        links[4] = "https://www.youtube.com";
        links[5] = "https://www.bing.com";

    var i = Math.floor(Math.random() * links.length);

$w('#button1').onClick.link = 'links[i]';
$w('#button1').onClick.target = '_self';
return false;}

All you have to do are 3-4 steps.

  1. Add a button onto the page → with the id → ‘button1’

  2. Add an event-trigger → onClick() ← of the ‘button1’ (property-panel of button)
    You will see changes inside your code, which will add the exported button-function automatically to your code.

  3. Now you can select the whole already existing code on your page and replace it with your shown code, since the function of button1 is already included inside of your code (you do not need it DOUBLED)

  4. After you have added your code → publish your website and test the function, or test it in PREVIEW-MODE.