I’m trying to find a solution to make a loop (Javascript) until the array of object is empty. Here the object that I want to use :
"chain": {
"evolves_to": [{
"evolves_to": [{
"evolves_to": [],
"species": {
"name": "nidoqueen"
}
}],
"species": {
"name": "nidorina"
}
}],
"species": {
"name": "nidoran-f"
}
}
I would like to loop until to find the variable evolves_to
empty. and in each loop using the species.name
, to list the evolution, in my case :
nidoran-f -> nidorina -> nidoqueen
I can not find yet a good way to do it. A bit lost. Thank you for your help 😉