I’m trying to get a couple of pages to have random titles.. Yes, yes.. I know in the year of our lord 2025..
I’ve seen examples that show how to do small arrays in page but I’m looking to randomize from a very large line separated file. I could do minimal formatting to allow JS to work but the main thing is that I need to load it from a separate file with the extension JS because JS I guess has issues with externally loading just any file extension.
No, I don’t actually know how to write JS. I do however know what a javascript file that should run looks like.. I know InnerHTML is involved to change the actual title tag itself.
Thanks for any leads anyone may have.
const titles = [
"Welcome to My Website!",
"Discover Amazing Things",
"Check Out Our Latest Offers",
"Your One-Stop Shop",
"Don't Miss Out!"
];
function changeTitleRandomly() {
const randomIndex = Math.floor(Math.random() * titles.length);
document.title = titles[randomIndex];
}