title: Check if a big object have null value
body: <p>I'm trying to make a function to go through an object and if is there any null values. Here is my code:</p>
  
  <pre><code>  async function validateObjectField(course) {
    let error = new Error();
    const keys = Object.keys(course);
    keys.forEach(k =&gt; {
      const obj = course[k];
      if (typeof obj === "object") {
        if (Array.isArray(obj)) {
          if (Object.size(obj) === 0) {
            error.message = `${obj} is required!`;
            return error;
          }
          for (const o of obj) {
            error = validateObjectField(o);
            if (error) return error;
          }
        } else {
          error = validateObjectField(obj);
          if (error) return error;
        }
      }
      if ((typeof obj === "string" &amp;&amp; obj.length === 0) || obj === null) {
        error.message = `${obj} is required!`;
        return error;
      }
    });
  }
  </code></pre>
  
  <p>I'm using console.log() to observe and see that sometimes the code goes to return statement but the remaining code is still executed. Anyone know why? I got stuck and have no idea what to do now.</p>
  
  <p>In this block of codes:</p>
  
  <pre><code>if (obj.length === 0) {
      error.message = `${obj} is required!`;
      return error;
  }
  </code></pre>
  
  <p>It did not return the error and break the function.</p>