You can redirect the user to a different page with pure JS by changing the global property window.location.

Here’s how it’s done:

window.location.replace("https://learn.coderslang.com");

This code sample redirects the user to the website https://learn.coderslang.com and it’s an equivalent of the HTTP redirect.

If you’re looking for the behaviour that’s similar to clicking a link, you should update the property window.location.href

window.location.href = "https://learn.coderslang.com";

Whatever you choose the user will end up redirected to a new web page.