Created
September 11, 2022 09:41
-
-
Save NhanKhangg98/8d5a74340f7866bf50f35a2c0cc6a6f9 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 trips = [ | |
| {to:'Brazil',distance:1000}, | |
| {to:'Chine',distance: 2500}, | |
| {to:'India',distance: 3000} | |
| ] | |
| const initialValue = 0; | |
| const sumWithInitial = trips.reduce( | |
| (previousValue, currentValue) => previousValue += currentValue.distance, | |
| initialValue | |
| ); | |
| console.log(sumWithInitial); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment