title: getElementByID return null but console.log works fine
body: <p>I am learning HTML/Javascript, and am writing some simple functions. I used console.log to return an element, and it returned fine, however, in the same function, when I try to use getElementById(), then I received an error in the console which says that the value is null. Could you help me understand what is wrong? </p>
  
  <pre><code>function calculateProfict() {
     var consumoW_H = 2960;
     var consumoW_D = 2960 * 24 * 0.001; 
     var prezzoElettricita = 0.22;
     var consumoElettricita_D = consumoW_D * prezzoElettricita;
     var valore_BTC = 12.5;
     var valore_BTC_D = 144 * valore_BTC;
     var hashrateGlobal = 100000000
     var networkHashratePercentage = document.getElementById("networkHashrate").innerHTML/hashrateGlobal;
     var BTC_D = networkHashratePercentage * valore_BTC_D;
     var euroBTC_D = BTC_D * 6471.90;
     var guadagno = euroBTC_D - consumoElettricita_D;
     console.log(guadagno) //Return -15.62
     document.getElementById("guadagno").innerHTML = guadagno; //null is not an object
  
  }
  </code></pre>
  
  <p>I also tried with .value (I don't know if it's right or not) but I received the same error. My point is why I can use console.log and not document.getElementById? Thanks guys and happy new year</p>