Filter by inner key with javascript/react

I’m making a page with React. I have a function that shows my all jobs, I want to write it to only give me ones that match an id. My code in jsx:

                   <tbody>
                       {jobs && jobs.map(job =>
                           <tr key={job.id}>
                               <td>{job.status}</td>
                               <td>{job.fk_product}</td>
                               <td>{job.fk_order}</td>
                               <td>{job.type}</td>
                               <td>{job.fk_employee}</td>
                               <td style={{ whiteSpace: 'nowrap' }}>
                               </td>
                           </tr>
                       )}
                   </tbody>

How can I rewrite this so that it filters it by job.fk_employee? For example if(fk_employee == 5) only then should all the values be mapped. (map not by job.id but by job.fk_employee)

Answer

You can filter it before mapping:

{jobs && jobs.filter(job => job.fk_employee === 5).map(job =>
  <tr key={job.id}>
    <td>{job.status}</td>
    <td>{job.fk_product}</td>
    <td>{job.fk_order}</td>
    <td>{job.type}</td>
    <td>{job.fk_employee}</td>
    <td style={{ whiteSpace: 'nowrap' }}>
    </td>
  </tr>
)}

or outside the render

const jobsFiltered = jobs.filter(job => job.fk_employee === 5)
...
{jobsFiltered.map(job => ...)}