This post is a pre-requisite for the following posts on key operations to manipulate the collections.
Traversing an array
If you were asked to print all the elements in an array, the IMPERATIVE way to solve this problem would be to use the for loop as shown below. In this approach, we have to specify how do we want to traverse the array.
As our goal is to process each element in the array, we can simply abstract this complexity using DECLARATIVE aka FUNCTIONAL way, using
The declarative approach hides the complexity of how to traverse the array, so you can focus on what to do with each item