Hi guys Im trying to print a list of scores saved within a database, ive got the data as JSON data (see below)

I am trying to print all each object within the "Scores" array using the following code
function showScores() {
var ourRequest = new XMLHttpRequest();
var x, i = "";
ourRequest.open('GET', '/allScores');
ourRequest.onload = function() {
var ourData = JSON.parse(ourRequest.responseText);
for (i in ourData.scores) {
x += ourData.scores[i] + "<br>";
}
document.getElementById("scoresList").innerHTML = x;
};
ourRequest.send();
}
However it is printing out the following
Any help with this is greatly appreciated, thanks guys

xshould be initialized. Try with this version:function showScores() { var ourRequest = new XMLHttpRequest(), x = ""; ourRequest.open('GET', '/allScores'); ourRequest.onload = function() { var ourData = JSON.parse(ourRequest.responseText); for (var i in ourData.scores) { x += ourData.scores[i] + "<br>"; } document.getElementById("scoresList").innerHTML = x; }; ourRequest.send(); }.x += ourData.scores[i]This is just appending a raw object to your HTML string. Javascript can’t magically parse this into HTML for you, so it just outputs[object Object]. You could access individual parts of this object and print those instead (eg:x += ourData.scores[i].Away_score)