Димитр,
<!DOCTYPE HTML>
<html>
<head>
<title>Untitled</title>
<style type="text/css">
.big {
width: 200px;
height: 200px;
}
.red {
background-color: red;
}
.yellow {
background-color: yellow;
}
.green {
background-color: green;
}
</style>
</head>
<body>
<div class="big">click me</div>
<script>
const elem = document.querySelector('.big');
let flag = 0;
const change = () => {
const colors = ["red", "yellow", "green"]
elem.className = `big ${colors[flag]}`
flag = (flag + 1) % colors.length
console.log(flag);
return flag;
}
elem.addEventListener('click', change);
</script>
</body>
</html>