Just a heads up - I am completely new to coding and JavaScript, and this happens to be my very first post, so please bear with me.
I have a set of Hex codes representing various colors, and my goal is to utilize JQuery to style some empty divs in the HTML using these colors. These divs are identified by the class "square," contained within a main tag, and have defined height and width in CSS. I have verified that they exist on the page. The objective is to apply the colors from the array to these divs in sequence.
This is my HTML structure:
<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 here is the color array:
let colors = ['#7e6493', '#895782', '#944a71', '#9f3c60', '#aa2f4f']
let $gameSquares = $('.square');
Essentially, what I need is a function that will go through the array of Hex colors and apply them one by one to the background of the divs.
I appreciate your help in advance.