(array)
| 10 | */ |
| 11 | |
| 12 | function nestedAdd(array) { |
| 13 | let sum = 0; |
| 14 | for (let i = 0; i < array.length; i++) { |
| 15 | const current = array[i]; |
| 16 | if (Array.isArray(current)) { |
| 17 | sum += nestedAdd(current); |
| 18 | } else { |
| 19 | sum += current; |
| 20 | } |
| 21 | } |
| 22 | return sum; |
| 23 | } |
| 24 | |
| 25 | test("nested arrays addition", () => { |
| 26 | expect(nestedAdd([1, 2, 3])).toEqual(6); |
no outgoing calls
no test coverage detected