const colors = ['red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet']; //for...of - loop const spans = document.querySelectorAll("span"); let count = 0 for (let span of spans){ span.style.color = colors[count] count++ } //alternative: //for-loop const spans = document.querySelectorAll('span'); for(let i =0; i< colors.length; i++){ spans[i].style.color = colors[i]; }