I have an object of objects in which I want to print all the name values, how can I do this easily without having to hardcode each one?
const myObj = {
results: {
one: {
name: "o",
value: 1
}
two: {
name: "t",
value: 2
}
}
ignore: "this"
}
I can make it work with myObj.results.one.name
, but I'd rather be able to do something like a loop where I can swap out the middle value like results.[1].name
preventing the hard coding of 20 values.
Is there a simple way to do this without hardcoding each one. (The end use is to add them all to an array and use that to populate a table to show name and values)
This linked answer doesn't answer my question as this is an array of objects so solutions fail, and the second isn't nested