I have 10 arrays of color styles in my JavaScript file. What I need is to check if the currently selected value in a dropdown list is equal to one of the array names I created, and assign the array once changed.
Here are 2 of the arrays:
var red = {
primary_color: 'red',
primary_hover_color: 'black',
menu_color: '#9c9fa3'
}
var yellow = {
primary_color: '#22c39b',
primary_hover_color: '#187e65',
menu_color: '#9c9fa3'
}
Then I also have this for the dropdown:
$('#color_palette').change(function() {
var palette = $(this).val();
if (palette = 'red') { palette = red }
if (palette = 'yellow') { palette = yellow }
// etc etc
});
I was wondering if there's a shorthand version of this instead of having to check an if condition for each value and make this more 'dynamic' rather than hardcode each color value in the condition.