title: Loop through an object and only return certain keys together with their values
body: <p>Given the following object, how can I loop through this object inorder to obtain both keys and values but only for the following keys:</p>
  <pre><code>    &quot;myName&quot;: &quot;Demo&quot;
      &quot;active&quot;: &quot;Y&quot;
      &quot;myCode&quot;: &quot;123456789&quot;
      &quot;myType&quot;: 1
  
  
  let a = {
      &quot;values&quot;: {
          &quot;myName&quot;: &quot;Demo&quot;,
          &quot;active&quot;: &quot;Y&quot;,
          &quot;myCode&quot;: &quot;123456789&quot;,
          &quot;myType&quot;: 1,
          &quot;myGroups&quot;: [
              {
                  &quot;myGroupName&quot;: &quot;Group 1&quot;,
                  &quot;myTypes&quot;: [
                      {
                          &quot;myTypeName&quot;: &quot;323232&quot;,
                          &quot;myTypeId&quot;: &quot;1&quot;
                      }
                  ]
              },
              {
                  &quot;myGroupName&quot;: &quot;Group 2&quot;,
                  &quot;myTypes&quot;: [
                      {
                          &quot;myTypeName&quot;: &quot;523232&quot;,
                          &quot;myTypeId&quot;: &quot;2&quot;
                      }
                  ]
              }
          ]
      }
  }
  </code></pre>
  <p>I have tried:</p>
  <pre><code>for (const [key, value] of Object.entries(a.values)) {
    console.log(`${key}: ${value}`);
  For}
  </code></pre>
  <p>but this will return all keys with their values.</p>