candidatePanel.textContent = ''; would be simpler here.  Do you really need the emptyElement() function?