I am trying to go to external url from my website with this code
var embed = "www.youtube.com";
console.log(embed);
window.location.assign(embed);
However, the webpage doesn't go to the the link in var embed but go instead to Mywebsite/thepageofthatcode/www.youtube.com
window.location = "www.youtube.com";
window.location.href = "www.youtube.com";
I didn't get why is this happening?