I am trying to return an array of colors dependant on the number of values I have in a seperate array. For example I have an array of values [1, 5, 12, 23, 33, 76, 100, 354, 123], values.length = 9. My array of colors has 8 entries, therefore my array of colors should continue to loop until it reaches 9 entries. The below bar chart is what I want to achieve, the chart may have 100 entries therefor the colors would continue to loop until they reach 100 entries. The below works with the following code however this is returning 9*8 entries in the console.log as im looping over each value and pushing in the colors array. The result should be a single colors array of 9 entries. Appreciate any help.
const barColors = () => {
const colorsArr = [];
// const colorsArr = ['rgba(3, 4, 94, 1)', 'rgba(3, 4, 94, .8)', 'rgba(3, 4, 94, .6)', 'rgba(3, 4, 94, .4)', 'rgba(3, 4, 94, .2)', 'rgba(3, 4, 94, .4)', 'rgba(3, 4, 94, .6)', 'rgba(3, 4, 94, .8)'];
const values = [1, 5, 12, 23, 33, 76, 100, 354, 123];
values.forEach(() =>
colorsArr.push(
'rgba(3, 4, 94, 1)',
'rgba(3, 4, 94, .8)',
'rgba(3, 4, 94, .6)',
'rgba(3, 4, 94, .4)',
'rgba(3, 4, 94, .2)',
'rgba(3, 4, 94, .4)',
'rgba(3, 4, 94, .6)',
'rgba(3, 4, 94, .8)'
)
);
console.log(colorsArr);
return colorsArr;
};


colorsArrhardcoded or dynamic? What's its relationship withvalues? Do you expect for each value to correspond to one single color with different alpha or completely different palette?