Code id to give the heading an ID.

<html>
<head>
</head>
<body>
  <h1 id="mainTitle">World News</h1>
  <script>var text = document.getElementById("mainTitle").innerHTML;
console.log(text);</script>
</body>
</html>]]>

Make sure to type id.