FOAP-NetMind-2022 / beetlepush

Learn JavaScript array methods
https://beetlepush.vercel.app/
Mozilla Public License 2.0
4 stars 0 forks source link

Array methods introduction #70

Open omiras opened 1 year ago

omiras commented 1 year ago

It would be nice to have some exercises that explain how to use array methods, rather than the array methods themselves. I'm not sure if that should be a separate section, or maybe they could be introductory exercises before a given array of methods to explain the topic.

The main topics that should be covered are:

  1. Array methods and parameters. Explain that array methods are used IN arrays, but that can have some parameters. For example, push methods
  2. Some methods modify the original array, and some others don't. For example, map creates a new array, whereas sort just modifies the original arrayç
  3. Callback function. It is key to understanding how callback functions work in array methods. For example, explain that the callback function in the filter method will keep the element in the array provided that the function evaluates a true for a given item
  4. Related to previous points, explain how callback function work, They are invoked for each item in the array.
  5. Explain the three possibles ways to pass a callback function to an array method:
    1. named function : myArray.filter(filterFunction);
    2. arrow function: myArray.filter(()=> { // do work // return ...})
    3. one-line-arrow-function: myArray.filter( x=> x > 10)
  6. Yet again related to previous point, explain the concept of predicate