0👍
✅
1. Replace
2. Ensure you’re testing the array length correctly using
1. Replace forEach
with map
link.children.map(child => {
u.makeLinkObj(child);
})
which can also be written as
link.children.map(u.makeLinkObj)
2. Ensure you’re testing the array length correctly using array.length
link.children > 0
will always be false
:
const link = {
children: [1,2,3,4,5]
}
console.log(link.children > 0) // <-- false
console.log(link.children.length > 0) // <-- true
References
Source:stackexchange.com