Skip to main content
Post Closed as "Duplicate" by Eddie, Amit javascript
added 84 characters in body
Source Link
user3142695
  • 17.5k
  • 56
  • 204
  • 377

I'm using a nested array like this:

const data = [
  [0],
  [2],
  [[1], 3]
  1
]

Is it possible to count all values together. In this example the result should be 7 (0+2+1+3+1). And is it also possible to count how many arrays are used? This would be 5 arrays

I'm using a nested array like this:

const data = [
  [0],
  [2],
  [[1], 3]
  1
]

Is it possible to count all values together. In this example the result should be 7 (0+2+1+3+1)

I'm using a nested array like this:

const data = [
  [0],
  [2],
  [[1], 3]
  1
]

Is it possible to count all values together. In this example the result should be 7 (0+2+1+3+1). And is it also possible to count how many arrays are used? This would be 5 arrays

Source Link
user3142695
  • 17.5k
  • 56
  • 204
  • 377

JS: How to count all values in nested array

I'm using a nested array like this:

const data = [
  [0],
  [2],
  [[1], 3]
  1
]

Is it possible to count all values together. In this example the result should be 7 (0+2+1+3+1)