Comments (3)
They're using different demo functions, and their return values are consistent with those functions. Returning the sum is just a common example use case for [].reduce
.
[].reduce
starts at the beginning of the array and works its way to the end. [].reduceRight
starts at the end and works its way to the beginning. I think the example for [].reduceRight
used in the pen might be mildly confusing for those still learning since it reduces nested arrays. Here's an example of both using the same function; note how the output differs:
['a', 'b', 'c', 'd'].reduce((current, carry) => current+carry); // ➡ abcd
['a', 'b', 'c', 'd'].reduceRight((current, carry) => current+carry); // ➡ dcba
from array-explorer.
Yeah @QWp6t you're right, I should make that a little more clear and easy to understand for beginners, since that's who this resource is for.
from array-explorer.
@sdras - hello! Can I work on this issue? 🙂
from array-explorer.
Related Issues (20)
- Immutable examples?
- Some sentences is not clear
- Error due to bumping webpack-dev-server from 2.11.3 to 3.1.11 HOT 1
- Install error 'Error: Cannot find module 'webpack-cli/bin/config-yargs' HOT 1
- add Persian language HOT 1
- typo bug HOT 1
- u are so beautify HOT 1
- Latest language details HOT 1
- Usage and Output animation is not visible HOT 2
- As a newbie who comes across this site, I would like to know which programming language is being used. HOT 2
- Possible typo in English version HOT 2
- Browser Support or ECMAScript Specification Warning HOT 1
- Change sort() example HOT 1
- let vs const as default, your opinion ? HOT 3
- Can you provide reverse operation HOT 1
- excuse me...what it's is? HOT 3
- indexOf: fromIndex HOT 2
- incorrect URL to demo page HOT 1
- Cloning an array HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from array-explorer.