Learn Enough JavaScript to be Dangerous: A Tutorial Introduction to Programming with JavaScript by Michael Hartl

Learn Enough JavaScript to be Dangerous: A Tutorial Introduction to Programming with JavaScript by Michael Hartl

Author:Michael Hartl [Michael Hartl]
Language: eng
Format: epub, pdf
Publisher: Addison-Wesley Professional
Published: 2022-05-18T16:00:00+00:00


6.3 Reduce

We reach finally the third member of our triumvirate, the mighty reduce (Figure 6.6)7—by far the most complicated of the three.

7. Image courtesy of colaimages/Alamy Stock Photo.

Figure 6.6: The third triumvir, Gnaeus Pompēius Magnus (Pompey the Great).

Because reduce is particularly challenging, we’ll cover two examples: First, we’ll make iterative and functional versions of a sum operation on arrays of integers; second, we’ll make a plain JavaScript object (Section 4.4) that maps state names to the length of each name, with a result that will look like this:

{ "Kansas": 6, "Nebraska": 8, . . . }



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.