Answer the question
In order to leave comments, you need to log in
How to iterate over nested object?
I have such an object
const aside = {
well: {
name: "Колодец",
costs: "200/250/300",
src: "../images/shop/wells/well-01.png"
},
depot: {
name: "Склад",
costs: "150/200/250",
src: "../images/shop/depots/depot-01.png"
},
cage: {
name: "Клетка",
costs: "100/150/200",
src: "../images/shop/cages/cage-01.png"
}
};
Answer the question
In order to leave comments, you need to log in
And what is the difficulty?
Options:
1) 2 nested for...in loops https://developer.mozilla.org/ru/docs/Web/JavaScri...
2) Option 1 via the .map method, if converted to an array via Object .keys / Object.entries
3) You can write a recursive traversal, but with limited nesting - why?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question