DEV Community

pouya alamdari
pouya alamdari

Posted on

for ... in ... with object

const person = {
    firstName: 'John',
    lastName: 'Doe',
    age: 21,
};

let text = "";
for (let x in person) {
    text += person[x] + " ";
    console.log(text);
}

console.log(text);
Enter fullscreen mode Exit fullscreen mode

Image description

Top comments (0)