title: JS: How to concatenate variables inside appendChild()?
body: <p>I'm trying to append a text node into a paragraph with values taken from its parent function's parameters.</p>
  
  <pre><code>function writeText(id, value, text) {
  
      //create our html elements
  
      var body = document.body;
      var par = document.createElement("p");
          par.className = id;
      this.value = document.createTextNode(value);
      this.text = document.createTextNode(text);
  
      //instantiate array that we will push value and text into
  
      textToInsert = [];
      textToInsert.push(this.value, this.text);
  
      //appends this.text and this.value inside the paragraph
      //and then appends that paragraph element into the body
  
      par.appendChild(textToInsert.join(' :'); //this does not work!
      par.appendChild(this.value+this.text); //this does not work!
      par.appendChild(this.value); //this works!
      body.appendChild(par);       
  }
  </code></pre>
  
  <p>This code is giving me the error message </p>
  
  <pre><code>Failed to execute 'appendChild' on 'Node': parameter 1 is not of type 'Node'.
  </code></pre>
  
  <p>So I take it that <code>join()</code> does not generate nodes. How can I concatenate two variables inside one <code>appendChild()</code>?</p>