title: typeerror cannot read property 'currenttarget' of undefined
body: <p>When running the below mentioned code, I get the errormessage: "TypeError: Cannot read property 'currentTarget' of undefined".</p>
  
  <p>Is it because I have currentTarget mentioned 2 places?</p>
  
  <p>When only running 1 function "deleteFood" it doesnt give any errors.</p>
  
  <pre><code>&lt;script&gt;
  let cB = document.getElementsByClassName("deleteFoodClass");
  var anyBoxesUnchecked = [];
  for (i = 0; i &lt; cB.length; i++) {
      cB[i].addEventListener('click', checkBoxMarked);
  }
  
  function checkBoxMarked(arg) {
      var trueBoolean = "true";
      let elm = arg.currentTarget;
      let marked = elm.getAttribute('data-IngredientMarked');
      let id = elm.getAttribute('data-ingredientID');
  
      if(marked === true){
          anyBoxesUnchecked.push(id);      // ... and adding them to the array.
      } else
          anyBoxesUnchecked.splice(id);
  }
  
  function deleteFood(arg) {
      let el = arg.currentTarget;
      let id = el.getAttribute('data-ingredientID');
  
      console.log(id); // used for debugging
  
      var url = '/api/Ingredients/';
      var urlQuery = url.concat(id);
      for (i = 0; i &lt; anyBoxesUnchecked.length; i++) {
      fetch(urlQuery,
          {
              method: 'GET',
              body: undefined,
              headers: {
                  "Content-type": "application/json; charset=UTF-8"
              }
          })
          //.then(res =&gt; res.json())
          .catch(error =&gt; console.error('Error', error))
          .then(response =&gt; console.log('Sucess On Deletion', response));
      }
  }
  
  &lt;/script&gt;
  </code></pre>
  
  <p>EDITED: It gives the following errors when trying to debug:
  <a href="https://i.stack.imgur.com/GoC3x.png" rel="nofollow noreferrer">Picture of debug message</a></p>
  
  <p>SOLUTION: Found out that - for some reason, given that checkBoxMarked never was called - I tried replacing it with "function()", which solved the problem.</p>