fac-15 / Who-am-I-API

0 stars 0 forks source link

Does the HP need to be inside an IIFE? #36

Open developess opened 6 years ago

developess commented 6 years ago

Using an event listener on the button might be more effective?

e.g.

  const userName = document.getElementById('github-user-name');
  const button = document.getElementById('submit-button');
  let index;

  button.addEventListener('click',function(e) {
    e.preventDefault()
    let name = userName.value.toLowerCase()
    let sum = 0;
    for (let i = 0; i < name.length; i++) {
      let code = name.charCodeAt(i);
      sum += code;
    }
    index = sum % 25;
    makeRequest(hpObjUrl, hpNameCallback);
  })