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:
@ -0,0 +1,5 @@
|
||||
# javascript-recursive - cats-childrens-of-childrens
|
||||
|
||||
Programming language : JavaScript
|
||||
|
||||
Created by [@Divlo](https://github.com/Divlo) on 12 September 2020.
|
@ -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
|
Reference in New Issue
Block a user