Emma, it seems you’ve received some great advice already. Let’s go through the tasks with some additional explanation to help solidify your understanding.
Additional Explanation for Task 1: The filter() method is a powerful array method that creates a new array with all elements that pass the test implemented by the provided function. In this task, it helps us create a list of names that have more than four characters.
This one-liner function iterates over each name, checking its length property against the condition name.length > 4.
Additional Explanation for Task 2: To summarize the frequency of each state in an array, using reduce() is very efficient. reduce() is perfect for aggregating values into a single result, like an object.
By utilizing a callback function, it accumulates the occurrences of each state in the accumulator object, initializing nonexistent keys with 0 before incrementing them.
Hopefully, these additional details help you understand how these functions work and why such methods are beneficial. Feel free to experiment further and ask any questions!