let seats = []; for (let i = 0; i < 19; i++) { seats.push({ x: 2 + i * 58, y: 236, bookStatus: '', selected: false, cycleSeatsLocation: 36 + i, toString: function() { return "{x:"+this.x+",y:"+this.y+",bookStatus:"+this.bookStatus+"'',selected:"+this.selected+",cycleSeatsLocation:"+this.cycleSeatsLocation+"}" } }, ) } let str = ''; seats.forEach(item=>{str+=item.toString()+',\n' }) console.log(str)