I'm practising my JavaScript skills a came up with an idea of a button that changes through an array of colours every time I click it.
const button = document.querySelector('button');
const colours = ['red', 'yellow', 'green', 'blue'];
let cycle = 1;
button.style.backgroundColor = colours[0];
button.addEventListener('click', e => {
button.style.backgroundColor = colours[cycle];
cycle++;
if (cycle == 4) {
cycle = 0;
};
});