title: How to return condition full fill object directly in typescript?
body: <p>I need to filter some array data and return only condition fulfill object. I try to like the below code. but <code>filterModel[0]</code> returns the first element of the filter array, not the condition full fill object. need some expert help to refactor this code, return <code>filterModel</code> ,which only this condition true <code>dInstance =&gt; dInstance.id === Id</code>.</p>
  <pre><code>export function getDModel(Id: string, data: DataModel): filterModel | undefined {
    const filterModel = data.valus?.filter(
      value =&gt; {
        const doseInstances = value.dInstances?.filter(dInstance =&gt; dInstance.id === Id);
        if (dInstances) {
          return true;
        } else {
          return false;
        }
      }
    );
    return filterModel &amp;&amp; isNotNulAndNotEmpty(filterModel) ? filterModel[0] : undefined;
  }
  </code></pre>