1
1
mirror of https://github.com/theoludwig/programming-challenges.git synced 2025-05-18 12:02:53 +02:00

feat: add cats-childrens-of-childrens challenge

This commit is contained in:
Divlo
2020-09-12 22:03:17 +00:00
parent 905b16289c
commit c81d766bae
5 changed files with 113 additions and 0 deletions

View File

@ -0,0 +1,5 @@
# javascript-recursive - cats-childrens-of-childrens
Programming language : JavaScript
Created by [@Divlo](https://github.com/Divlo) on 12 September 2020.

View File

@ -0,0 +1,12 @@
function solution (folders, result = []) {
for (const folder of folders) {
if (folder.type === 'image') {
result.push(folder.name)
} else if (folder.type === 'folder') {
solution(folder.children, result)
}
}
return result
}
module.exports = solution