Hi,
I’m very new to JS and am currently learning the language for the sole purpose of adding a random page button to my website. It looks pretty close to the tutorial I was looking at, but still will not work for some reason. Any ideas why? This is what I have so far:
const pages = [
"https://benitengu.neocities.org/",
"https://benitengu.neocities.org/about",
"https://benitengu.neocities.org/virtualpets.html",
"https://benitengu.neocities.org/bestiary.html",
"https://benitengu.neocities.org/shrimp.html",
"https://benitengu.neocities.org/links.html",
"https://benitengu.neocities.org/coding.html",
"https://benitengu.neocities.org/hoard.html",
"https://benitengu.neocities.org/curios.html",
"https://benitengu.neocities.org/reading.html",
"https://benitengu.neocities.org/misc.html",
"https://benitengu.neocities.org/hellenicpaganism.html",
"https://benitengu.neocities.org/heathenry.html",
"https://benitengu.neocities.org/kemeticism.html",
"https://benitengu.neocities.org/baltic.html",
"https://benitengu.neocities.org/updates.html",
"https://benitengu.neocities.org/now.html",
"https://benitengu.neocities.org/shrines.html",
"https://benitengu.neocities.org/fanlistings.html",
"https://benitengu.neocities.org/shrines/nidai/",
"https://benitengu.neocities.org/shrines/tsumugi/",
"https://benitengu.neocities.org/shrines/madara/",
"https://benitengu.neocities.org/coding.html",
"https://benitengu.neocities.org/collections.html",
"https://benitengu.neocities.org/collections/boloties.html",
"https://benitengu.neocities.org/collections/civildefense.html",
"https://benitengu.neocities.org/collections/plushietags.html",
"https://benitengu.neocities.org/collections/cameras.html",
"https://benitengu.neocities.org/collections/newvegas.html"
];
if (url.contains("reading", "tcg", "nidai", "tsumugi", "madara", "coding"));
add ("target=_blank");
document.getElementById("randomLinkBtn").addEventListener("click", () => {
const randomIndex = Math.floor(Math.random() * pages.length);
const randomPage = pages[randomIndex];
window.location.href = randomPage;
});