title: Unexpected results from a function
body: <p>I have the following two blocks of code that I am trying to debug.</p>
  
  <pre><code>function getSectionId(target){
    let element = target;
    if(element.hasAttribute('id')){
      console.log(element.id); 
      return element.id;
    } 
    else {
      getSectionId(element.parentElement);
    }
  };
  </code></pre>
  
  <pre><code>function coverageLimitHandler(event) {
    const target = event.target;
    if (target.getAttribute('data-status') !== 'set') {
      let itemBlock = addLineItem();
      let sectionId = getSectionId(target);
      let attribute = '';
      console.log(sectionId);
    }
  }
  </code></pre>
  
  <p>The event fires and the functions run, but the above gives the unexpected following results</p>
  
  <p>//first-coverage-section (this one is expected.)
  //undefined (this is expected to be the same, but is not.)</p>
  
  <p>And I cannot for the life of me figure out why this is happening.</p>