I am have created an array of colors. I am trying to use colors.forEach inside ready function to call addBox for each color in this array. The plan is that I see that all the colors have been added when the page is reloaded. Let me know if you need html code pls
function addBox(color) {
$('#colors').prepend('<div class="item" style="background-color: ' + color + ';"></div>');
}
var colors = ['22ac5e', 'd68236', '770077'];
// I think my problem lies after this line
$(document).ready(function () {
// var colors = ['22ac5e', 'd68236', '770077'];
colors.forEach(addBox(color))
});
Many thanks in advance.