Created
July 16, 2021 09:45
-
-
Save gbitdev/389067d533e8157b6125870c3fd11f39 to your computer and use it in GitHub Desktop.
Deep key search
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function findImages(page) { | |
| let imagesArray = []; | |
| JSON.stringify(page, (_, nestedValue) => { | |
| if (nestedValue) { | |
| if (nestedValue['images']) { | |
| imagesArray = [...imagesArray, ...nestedValue['images']]; | |
| } | |
| if (nestedValue['image']) { | |
| imagesArray = [...imagesArray, nestedValue['image']]; | |
| } | |
| } | |
| return nestedValue; | |
| }); | |
| return imagesArray; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment