let persons = [ { name: 'Sergey', surname: 'Honcharenko', age: 28, isMarried: false, }, { name: 'Andrew', surname: 'Klymchuk', middleName: 'Anatoliyovych', haveAJob: true, }, { name: 'Alexander', surname: 'Slobodian', sex: 'male', hasAPet: false, } ]; let personsKeys = []; for (let key in persons) { for (let value in persons[key]) { personsKeys.push(value); } } let personsUniqueKeys = new Set(personsKeys); let str = "
${item} | `; }); str += "|
---|---|
${persons[key][[...personsUniqueKeys][personsKey]]} | ` } else { str += `- | ` } } str += "