Created
January 12, 2023 02:55
-
-
Save WangNingning1994/30f7a55c86e110a96df8c351d97e98df to your computer and use it in GitHub Desktop.
double reduce to calculate total value of array that holding number
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const numArr = [ [1,2,3], [4,5,6] ]; | |
const initialValue = 0; | |
const totalNum = numArr.reduce( | |
(acc, curr) => acc + curr.reduce((acc_, curr_) => acc_ + curr_, 0), | |
initialValue | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment