Styling with JS and via lopping

PHOTO EMBED

Sat May 07 2022 14:57:01 GMT+0000 (Coordinated Universal Time)

Saved by @Luduwanda #javascriptreact

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];
} 

content_copyCOPY