Why isn't my code working?


So, i’m new to this and i self learning in this js area, this is probably a very simple problem but i’m stuck at this and can’t figure the reason why this line of code i built isn’t working, can someone help me?


var ab = 10;
var bc = 15;
var continha = ab + bc;

function total2(){
  return continha ;
document.getElementById("mat").innerHTML = total2();


<h3 id="mat"></h3>


seems fine, i put your code here:


don’t forget that a html document loads from top to bottom, so if you link to the js file before you defined the h3 element, the code won’t work.


Dont, worry about the messed up code, i’m just fooling around and experimenting how js reacts to html code. But here it is, as you can see i used a src script tag to link the js external file to the html document. My js code isn’t working only with this h3 “mat” tag. Can you see why this is happening?


but if somewhere in your experimental code it goes wrong, the problem might not be duplicable in the code you originally provided. So i do certainly worry about it.

and debugging from a screenshot is really difficult. I am not going to do that.