window.onload = function() { const xmlhttp = new XMLHttpRequest(); const formats = ["Espace accueil", "realite virtuelle", "musee numerique", "cyber base", "shooting photo", "jeux videos", "espace scenique"] // Get JSON File xmlhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { var myObj = JSON.parse(this.responseText); // Parse JSON file var dataInFile = myObj.usagers; // JSON data const freqBySpaceData = freqBySpace(dataInFile); displayfileData(dataInFile); createChartToDOM(freqBySpaceData.title, freqBySpaceData.espaceFormat, freqBySpaceData.key, freqBySpaceData.avePrice); var objReturn = avePriceByKey(dataInFile, "espace"); console.log(objReturn); } }; xmlhttp.open("GET", "js/usagers.json", true); xmlhttp.send(); }