display Arrays Object
hi i have one object : const obj = [ { name: "ahmad", family: "mahdavi", city: "kian", score: 10 }, { name: "ali", family: "Ahmadi", city: "Shahrekord", score: 5 }, { name: "reza", family: "rezaei", city: "tehran", score: 3 }, { name: "mohammad", family: "kiani", city: "shiraz", score: 19 } ]; let txt = ""; document.getElementById("p1").innerHTML = dis(); obj.sort( function (a, b) { return a.score - b.score; } ) document.getElementById("p2").innerHTML = dis(); function dis() { obj.forEach(element => { txt += element.name + " " + element.family + " " + element.city + " " + element.score + "<br>"; }) return txt; } it must 2 time print onject insted 3 time. why 3 time?