We were unable to load Disqus. If you are a moderator please see our troubleshooting guide.
What do you think of this as an alternative to question 7?
function totalIntegers(arr) { let total = 0; arr.forEach(item => { if (Array.isArray(item)) { total += totalIntegers(item) } else if (typeof item === 'number') { total++ } }) return total}
For Question #8 you don't need the base case if (arr.length === 0) return 0.
this is the best recursive tutorial i have ever seen
What do you think of this as an alternative to question 7?
function totalIntegers(arr) {
let total = 0;
arr.forEach(item => {
if (Array.isArray(item)) {
total += totalIntegers(item)
} else if (typeof item === 'number') {
total++
}
})
return total
}