Reducer Function
The reducer function, is a higher order function in js that combines elements of an array to produce one result. It takes in the array you want to perform operations on, with two arguments, the callback function, and the initial value.
reduce()
can be used for a wide variety of tasks, such as summing up array elements, finding the maximum or minimum value, flattening arrays, counting occurrences, and more.
Strings and character codes
JavaScript strings are encoded as a sequence of 16Bits numbers, these are called code units.
- This was the old way people uses to represent characters, this quickly became untenable and we had to create more reliable ways to represent strings in the computer.
- JavaScript provides a function that gives you a code unit of a given character.
- If you have a character (which will be a string of one or two code units), you can use
codePointAt(0)
to get its code.