Я думаю, вы хотите что-то вроде этого -
Обновлен код для требования
var colors = [
['red', 'green', 'blue'],
['teal', 'brown', 'tan'],
['orange', 'purple', 'black']
]
var boxed = document.querySelectorAll(".box");
var button = document.querySelector("button");
button.addEventListener("click", function () {
let colorIndex = Math.floor(Math.random() * 3);
for (i = 0; i < boxed.length; i++) {
boxed[i].style.backgroundColor = colors[colorIndex][i];
boxed[i].style.width = '100px';
boxed[i].style.height = '100px';
boxed[i].style.display = 'inline-block';
}
});
button.style.cursor = "pointer";
.box {
width: 100px;
height: 100px;
display: inline-block;
background: gray;
}
<div class="box">1</div>
<div class="box">2</div>
<div class="box">3</div>
<button>Theme</button>