Sobes.tech
Intern — Middle

Counting all integer elements in a nested array

livecode

Task condition

Given an array that may include both numbers and other arrays of arbitrary depth, implement a function that returns the total count of numerical values encountered at any level of the structure.

// Examples:
// console.log(getCountNum([[[][]]])); // 0
// console.log(getCountNum([[0, [1, [5, [4, 3], 1], 1]])); // 7
// console.log(getCountNum([[[[1], 2], 3, 4, [1, [5, 3, 0, [6, 7]]]]]));