I have the following HTML and Javascript code, but Chrome cannot allow me to run it, can anybody help me fix it up. HTML code is:
var myNodelist = document.getElementsByTagName("p");
document.getElementById("demo").innerHTML = "The innerHTML of the second paragraph is: " + myNodelist[1].innerHTML;
<p>Hello World!</p>
<p>The DOM is very useful!</p>
<p id="demo"></p>
The error message of Chrome is: Uncaught TypeError: Cannot read property 'innerHTML' of undefined