Fiddle: https://jsfiddle.net/3aq286rx/4/
I have an array which has nested arrays and objects
I wanted to label the colors like #f00 is red etc. etc.
I have a random number generator function which generates a random number from 0 to 2: getRandNUM(1)
Let's say the number is 2 I want to be able to pull #0f0 from my arrays without having to use .green because I wouldnt know the label based on the random number.
How can I do that
script:
var defaults = {
 backgroundcolor: '#000',
 color: '#fff',
 weekdays: ['sun','mon','tue','wed','thu','fri','sat'],
 colors: [
    {
    red: [
      "#f00"
      ]
  },
  {
    blue: [
      "#00f"
      ]
  },
  {
    green: [
      "#0f0"
      ]
  }
 ]
};
alert(defaults.colors[0].red);
 
     
    