whats wrong with this code? when i click on button it shows undefined before first array value:
function loadDoc() {
  var x;
  var edare = JSON.parse('{"names":["ali", "mansour", "taghi"]}');
  for (var i in edare.names) {
    x += edare.names[i] + "<br>";
    document.getElementById("demo").innerHTML = x;
  }
}<input type="button" onclick="loadDoc();" value="test">
<p id="demo"></p> 
     
     
    