Avatar ·

How to make a redirect to another web page in JavaScript?

Hello everyone! I'm a beginner in web development, writing my first site in pure HTML/CSS/JS. I've encountered what seems like a simple task: after the user clicks the "Login" button and passes validation (checking for empty fields), I need to redirect them to the personal account page. I've scoured tons of forums, but the solutions vary: some people write about `window.location`, some about `window.location.href`, some about `location.replace()`, and some recommend jQuery with `$(location).attr('href', ...)`. I'm completely confused. Here's my current code that doesn't work: ```javascript function login() { let username = document.getElementById('username').value; if (username === '') { alert('Enter name'); } else { // There should be a redirect to dashboard.html ```