1
1
mirror of https://github.com/theoludwig/programming-challenges.git synced 2024-12-08 00:45:29 +01:00
programming-challenges/challenges/cats-childrens-of-childrens/solutions/javascript-recursive/solution.js

13 lines
281 B
JavaScript
Raw Normal View History

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