Q:

Why aren't the child nodes of this paragraph attribute being displayed?

I am new to JavaScript, and I was putting some code on an editor to test it out. 
I am trying to dynamically create elements by appending child nodes to a "p" attribute, but I am not seeing these child nodes displayed. Could you please explain why, and how I can make all of the nodes to be displayed? 
Here is the code: 
<html> 
<head> 
<title>t1</title> 
<script type="text/javascript"> 
    function addNode() { 
    var newP = document.createElement("p"); 
        var textNode = document.createTextNode(" This is a new text node"); 
        newP.appendChild(textNode); 
    document.getElementById("firstP").appendChild(newP); 
  } 
</script> </head> 
<body> <p id="firstP">firstP<p> </body> 
</html>

Here is the output: firstP
I was expecting to get:
firstP
p
This is a new text node

UPDATE: I accepted the answer that worked. Also realized that I was supposed to expect the output to be:
firstP
This is a new text node

A:

You made typo error and child node need to be added to a p parent tag, so inserting the p tags into a div tag is better, also call the addNode function, this will work ;-)

<html>
<head> 
<title>t1</title> 
</head> 
<body>
    <div id="firstPContainer">
        <p>firstP</p>
    </div>
    <script type="text/javascript"> 
    function addNode() { 
        var newP = document.createElement("p"); 
            var textNode = document.createTextNode(" This is a new text node"); 
            newP.appendChild(textNode); 
            document.getElementById("firstPContainer").appendChild(newP); 
    }
    addNode();
</script>
</body> 
</html>

