I'm attempting to pull some URLs from an array and write them to the page as <a> HTML elements.
As you can see in the jsfiddle below, for some reason the href is being set as [object text] and the URLs are being added as the link text, which means they don't work. How can I make it such that the href is the URL from my array and the link text is either the URL as well, or something like 'click here'?
Code
var title = document.createTextNode(titles[i]),
author = document.createTextNode(authors[i]),
url = document.createTextNode(urls[i]),
titleX = document.createElement('h1'),
authorX = document.createElement('h2'),
urlX = document.createElement('a');
urlX.setAttribute('href', url);