JSFiddle - React, Tailwind, and code Playground

HTML

<div id="logoswap"></div>

CSS

#logoswap {
    height : 200px;
    width : 200px;
}

.class1 {
    background-color : #111;    
}
.class2 {
    background-color : #222;    
}
.class3 {
    background-color : #333;    
}
.class4 {
    background-color : #444;    
}
.class5 {
    background-color : #555;    
}
.class6 {
    background-color : #666;
}

JavaScript

function gen_url(){
    return parseInt( Math.random() * 10 % 6 ) + 1;
}

var x = '/test/item' + gen_url();
console.log( x );
  
$(function() {
  var rgx = /item(\d+)$/,
      url = x,
      id = (rgx.test(url)) ? url.match(rgx)[1] : '1';
  $("#logoswap").addClass("class" + id);
});