I use Javascript ES6 and have an issue.
I have an Array:
var commentList = [
{'id': 1, text: 'A', children: [{'id': 2, text: 'B' }] },
{'id': 4, text: 'asd', children: [] },
{'id': 5, text: 'vx', children: [{'id': 7, text: 'xxss' }] },
{'id': 8, text: 'ghfdh', children: [{'id': 15, text: 'I want to take this' }] },
{'id': 10, text: 'A', children: [{'id': 18, text: 'Bsda' }] },
]
This is an Array with Parent - Child Structure. How can I get Exactly object {'id': 15, text: 'I want to take this' } if I just have ID only
I tried but not work
var object = commentList.find(o => o.id === 15) => undefined