Further explained the challenge with a minor change.
Further explained the challenge. Modified the challenge description for better understanding Reverted back previous changes and further explained the terminology. Minor change
This commit is contained in:
@ -350,6 +350,7 @@
|
||||
"description": [
|
||||
"The array method <code>reduce</code> is used to iterate through an array and condense it into one value.",
|
||||
"To use <code>reduce</code> you pass in a callback whose arguments are an accumulator (in this case, <code>previousVal</code>) and the current value (<code>currentVal</code>).",
|
||||
"The accumulator is like a total that <code>reduce</code> keeps track of after each operation. The current value is just the next element in the array you're iterating through.",
|
||||
"<code>reduce</code> has an optional second argument which can be used to set the initial value of the accumulator. If no initial value is specified it will be the first array element and <code>currentVal</code> will start with the second array element.",
|
||||
"Here is an example of <code>reduce</code> being used to subtract all the values of an array:",
|
||||
"<blockquote>var singleVal = array.reduce(function(previousVal, currentVal) {<br> return previousVal - currentVal;<br>}, 0);</blockquote>",
|
||||
|
Reference in New Issue
Block a user