title: Using filter to return only specific property of the key
body: <p>I have an array object and inside that array object I need to filter and create an array based on <code>isVerfied</code> property. </p>
  
  <p>If <code>isVerfied</code> property is true,  I just need to push the name property of the object instead of pushing the entire object into an array</p>
  
  <p>I tried this but it doesn't seem to be working since it is pushing the entire object.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>const users = [
     {
           name: 'Varun', 
           age: '18', 
           isVerfied: 'true'
     }, 
     {
           name: 'Rahul', 
           age: '12', 
     }
  ]
   
  const verfiedUserNameNew = users.filter(user =&gt; {
       if (user.isVerfied) return user.name
  })
  
  console.log(verfiedUserNameNew) </code></pre>
  </div>
  </div>
  </p>
  
  <p>I tried with map as well </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>const users = [
    {
          name: 'Varun', 
          age: '18', 
          isVerfied: 'true'
    }, 
    {
          name: 'Rahul', 
          age: '12', 
    },
  ]
           
  const verfiedUserNameNew = users.map(user =&gt; {
    if (user.isVerfied) return user.name
  })
  
  console.log(verfiedUserNameNew)</code></pre>
  </div>
  </div>
  </p>
  
  <p>But then it return varun and undefined. i know an alternate solution can be to create an array and run a for.Each loop, put an if condition inside that loop and then push the element into an array   </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>const users = [
    {
          name: 'Varun', 
          age: '18', 
          isVerfied: 'true'
    }, 
    {
          name: 'Rahul', 
          age: '12', 
    },
  ]
       
  const newArray = []
  users.forEach(element =&gt; {
    if (element.isVerfied) {
          newArray.push(element.name) 
    } 
  }) 
       
  console.log(newArray)</code></pre>
  </div>
  </div>
  </p>
  
  <p>But I was thinking if we could achieve this using filter method? </p>