const cars={
cars1:{
name:"Suzuki",
model:565,
price:1200
},
cars2:{
name:"hyundai",
model:567,
price:1300
},
cars3:{
name:"toyata",
model:897,
price:2000
}
}
-
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
Add a comment
|
1 Answer
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);