0
const cars={
    cars1:{
        name:"Suzuki",
        model:565,
        price:1200
    },
    cars2:{
        name:"hyundai",
        model:567,
        price:1300
    },
    cars3:{
        name:"toyata",
        model:897,
        price:2000
    }
}
1
  • Hello, welcome to StackOverflow. Could you show what you have tried so that we can offer you some help?
    – Y.T.
    Commented Aug 15, 2021 at 12:09

1 Answer 1

0

Try looping through the object keys and return the name node of all keys.

const cars = {
    cars1: {
        name: "Suzuki",
        model: 565,
        price: 1200
    },
    cars2: {
        name: "hyundai",
        model: 567,
        price: 1300
    },
    cars3: {
        name: "toyata",
        model: 897,
        price: 2000
    }
}
const carModels = Object.keys(cars).map((key) => cars[key].name);
console.log(carModels);

Not the answer you're looking for? Browse other questions tagged or ask your own question.