-5
<h1>heelo</h1>
<script type ="text/javascript">
   //this all should redirect but does not
   alert('You are being redirected to random website')                            
   var responses = ["https://www.google.com",    "https://www.youtube.com"]
   var rand =  responses[Math.floor(Math.random() * responses.length)];
   window.location.replace(`${rand}`)
  }
showdev
  • 28,454
  • 37
  • 55
  • 73

1 Answers1

1

I changed the way the JavaScript variable is provided to replace().
It's simply rand rather than &grave;${rand}&grave;.

I also removed the unmatched closing } and added the matching closing </script>.

<h1>heelo</h1>
<script type ="text/javascript">
   alert('You are being redirected to random website')                            
   var responses = ["https://www.google.com",    "https://www.youtube.com"]
   var rand =  responses[Math.floor(Math.random() * responses.length)];
   window.location.replace(rand)
</script>
showdev
  • 28,454
  • 37
  • 55
  • 73