title: How to loop through an array and get the name corresponding to id and assign the result to another array
body: <p>I am new to typescript .please help me in doing this.
  I have an array as below.</p>
  
  <pre><code>let pets=[{id:"1",name:"animal"},{id:"2",name:"animal"}];
  </code></pre>
  
  <p>i want to loop through pets and get the names of animals from another array Category where </p>
  
  <pre><code>let category = [{id:"1",name:"Dog"},{id:"2",name:"Cats"},{id:"3",name:"Cows"},{id:"4",name:"Goat"}]
  </code></pre>
  
  <p>get output as below,</p>
  
  <pre><code>// expected output,
  newpets=[{id:"1",name:"Dog"},{id:"2",name:"Cats"}]
  </code></pre>