I am a software developer, passionate about developing and designing solutions with an emphasis on great user experience.
Code-collaboration | Writing | Learning | Open Source Contribution
Absolutely. In the second example, the value will be compared to the accumulator to find the maximum number in the array. The concept behind it works similar to example 1, in regards to how the accumulator and the value/currentValue work. For the fifth example, when we pass in the current value (color) of let's say, the color green, we will add it up to the accumulator and count it as the first instance. The current value will then move on to the next array element, which is blue, and do the same. If by any chance we find another instance of the color green existing in the color array, we will add it up to the accumulator, which already has an existing instance of the color green, and thus if we return the accumulator, we will find that green has two instances in the color array. Hope that explanation helped you out.