title: How do I check & return an error message if an array is undefined?
body: <p>I am writing a ternary statement that prints out the certification of a movie (IE. PG, R...).</p>
  <p>I am trying to return an error message that says &quot;No Certification Available For This Movie&quot; if the length of the array is equal to zero and if it is undefined. I managed to print the error message to the console if the array is equal to zero but I am struggling with printing an error message when it is undefined. I keep getting <code>TypeError: Cannot read properties of undefined (reading 'release_dates')</code> in the console.</p>
  <p>This is what I have tried:</p>
  <pre><code> const movieRating = rating.results;
  
   //Finding US ratings
   const findUSRating = movieRating.find((item) =&gt; item.iso_3166_1 === 'US');
  
  //Filtering US ratings to remove null certifications. 
   const array = findUSRating.release_dates.filter((item) =&gt; item.certification);
  
  //Ternary statement &amp; where I am stuck.
  console.log(array.length &gt; 0 || array[index] !== undefined ? array[0].certification : `No certification Available For This Movie`);
  </code></pre>