JSFiddle - React, Tailwind, and code Playground

HTML

<button>Change Background Color</button>

JavaScript

var colors = [
    "black",
    "blue",
    "yellow",
    "red",
    "white"
];

var counter = 0;

$('button').click(function(){
    if (counter == colors.length) { counter = 0; }
    var currentColor = colors[counter];
    $('body').css("background", currentColor);
    counter++;
});