I have some JS that currently gets the URL of a website, splits the URL to a particular string and stores it in a variable
I then have an IF statement that depending on that string will add a class to my links. However, the i can't get the IF statement to work. It seems to do the action even if the condition has been met.
Any help would be greatly appreciated!
https://codepen.io/Carrot654321/pen/YazXBv - Code here
const navLinks = document.querySelectorAll("nav ul li a")
var url = window.location.href;
url = url.split("/");
if (url[2] = "s.codepen.io") {
navLinks[1].classList.add("active");
}
else {
navLinks[3].classList.add("active");
}