title: JavaScript foreach objects
body: <p>I'm struggling with some algorithm with javascript. I'm using Vue as framework and state managament. I have an object that needs to be 'calculated' as variants.</p>
  <p>For example, I have 3 objects and in those objects some values as array, like so:</p>
  <pre><code>&quot;attributes&quot;:[
     {
        &quot;title&quot;:{
           &quot;text&quot;:&quot;Size&quot;,
           &quot;value&quot;:&quot;1&quot;
        },
        &quot;values&quot;:[
           &quot;M&quot;,
           &quot;L&quot;,
           &quot;X&quot;
        ]
     },
     {
        &quot;title&quot;:{
           &quot;text&quot;:&quot;Color&quot;,
           &quot;value&quot;:&quot;2&quot;
        },
        &quot;values&quot;:[
           &quot;Red&quot;,
           &quot;Green&quot;,
           &quot;Black&quot;
        ]
     },
     {
        &quot;title&quot;:{
           &quot;text&quot;:&quot;Material&quot;
        },
        &quot;values&quot;:[
           &quot;Cotton&quot;,
        ]
     }
  ]
  </code></pre>
  <p>So my state for this is obviously attributes.
  So what I really need to do is to foreach attribute values and create variant for every possible combination, and console.log them.
  Like so:</p>
  <blockquote>
  <p>M/Red/Cotton, L/Red/Cotton, X/Red/Cotton, M/Green/Cotton,
  L/Green/Cotton, X/Green/Cotton, M/Black/Cotton, L/Black/Cotton,
  X/Black/Cotton</p>
  </blockquote>
  <p>So I started function that will only foreach attributes, so I need to foreach values and make that codes (up) for them, but no idea how to proceed. So it  looks like:</p>
  <pre><code>addVariant: function (text) {
            this.attributes.forEach(element =&gt; console.log(element));
          },
  </code></pre>