Comments (2)
Syntax for reduce Function is like this...
[0, 1, 2, 3, 4].reduce(function(previousValue, currentValue, index, array) {
return previousValue + currentValue;
});
Reduce is an iterative method.. so each time previousValue , currentValue & index will be change..
In this scenario ,
1st iteration: previousValue = 0 & currentValue = 1
2nd iteration: previousValue = 1 & currentValue = 2
3rd iteration: previousValue = 3 & currentValue = 3
In your code you have used reduce method like this..
[ 'J', 'i', 'f', 'a', 's', 'N', 'i', 'f' ].reduce(function(previousValue, currentValue) {
return previousValue + currentValue;
});
So from this ,
1st iteration: soFar = 'J' & s = 'i'
2nd iteration: soFar = 'Ji' & s = 'f'
3rd iteration: soFar = 'Jif' & s = 'a'
You can find Help about reduce function here
from count-to-6.
Thanks @vishant-dhandha - thats tremendously useful. Cheers!
from count-to-6.
Related Issues (20)
- Tagged Templates HOT 4
- tagged template strings - escaping apostrophes HOT 3
- tagged template strings (step 8) location of colon
- node doesn't know about ES6 features HOT 1
- `let` keyword HOT 2
- Update to workshopper 2.x/workshopper-exercise 2.x HOT 3
- Move from traceour to babel (6to5) HOT 3
- rename es6 to es 2015? HOT 1
- HELLO ES6 example not working i.e. not verify..
- Extra Escape Character Rendered in Problem "Template Strings" HOT 2
- ... is an unexpected token (rest challenge) HOT 5
- Destructuring asignment misleading HOT 1
- What's the different between 'process.argv.slice(2)' and 'process.argv[2]'
- how do I move forward with the lesson or show solution? HOT 1
- DeprecationWarning? HOT 1
- can not start HOT 4
- Excercise #2 - error
- Binary file not created when installing package
- is this in active development or abandoned ?
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 count-to-6.