Use setAttribute
like this:
var createA = document.createElement('a');
var createAText = document.createTextNode(theCounter);
createA.setAttribute('href', "http://google.com");
createA.appendChild(createAText);
getTheTableTag.appendChild(createA);
A more interactive example:
const insertButton = document.getElementById('insertButton');
const appendAnchorTag = () => {
const anchor = document.createElement('a');
const list = document.getElementById('linksList');
const li = document.createElement('li');
anchor.href = 'http://google.com';
anchor.innerText = 'Go to Google';
li.appendChild(anchor);
list.appendChild(li);
};
insertButton.onclick = appendAnchorTag;
<button id="insertButton">Create New Anchor Tag</button>
<ul id="linksList"></ul>