Placement of my JavaScript

Hello People,

So i decided to create a page that when visited, redirects to another external URL selected from an array.

My code looks like in the attached file.code

My question is, where should I place this code on my “/random-page” for this to work in Webflow.
(Also, if you spot any errors in the code, please let me know).

Thank’s in advance!

I’d put this in Page Footer Code (before /body tag)

<script>
var links = [
  "https://google.com",
  "https://samliew.com",
  "https://webflow.com",
];
window.location = links[Math.floor(Math.random() * links.length)];
</script>

Also, feel free to contact me for further code help and/or customization of third-party plugins

Thank you very much @samliew that worked great!