Last active
October 6, 2020 18:27
-
-
Save hasinhayder/d113258a7b1cf8b343fb399bb8bfcea5 to your computer and use it in GitHub Desktop.
Extracting data and flattening it from a multi dimensional array
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
//data source = https://gist.github.com/hasinhayder/7352ac2d76660862061ffdd0d963711e | |
const videos = course.data.chapters | |
.map((chapter) => chapter.episodes.map((episode) => episode.vid)) | |
.flat() | |
//Another solution (By Shadman Shadab) | |
const videos = course.data.chapters | |
.flatMap((chapter) => chapter.episodes.map((episode) => episode.vid)) | |
// result = ["VAZz_eYJJ1M", "S_pJoNeMqj8", "vmgHZUD0v4c", "mmiPxxulXUk", "nrZAZ0DmrlM"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.