Quick disclaimer - I'm new to coding and JavaScript, and this is my first post so please go easy on me.
I have an array of Hex codes for colors and I want to use JQuery to style some empty div's in the HTML with the colors. The div's have a class of "square" and sit inside a main tag and have been given a height and width in CSS so I know they are there. I want to attach the array in order so the div's are colored in order.
This is my HTML:
<main>
<div class="Sample">
<div class="square"></div>
<div class="square"></div>
<div class="square"></div>
<div class="square"></div>
<div class="square"></div>
</div>
</main>
and this is the array:
let colors = ['#7e6493', '#895782', '#944a71', '#9f3c60', '#aa2f4f']
let $gameSquares = $('.square');
So ideally what I wanted was a function which changed the background colour of the div's one by one with the Hex colors from the array.
Thanks in advance.