JSFiddle - React, Tailwind, and code Playground

HTML

<input type='button' value='click' onclick="setCss()"/>

JavaScript

var cssName= [ 'CSS/katy.css', 'CSS/daftpunk.css', 'CSS/wiliam.css'];


function setCss(){
    var rndIndex = Math.floor(Math.random()*3);
    // Instead using here the console.log() you will do the following
    // document.getElementById('pagestyle').setAttribute('href', cssName[rndIndex]);
    alert(cssName[rndIndex]);
}