Iterate over Arrays with map - Question

Hi @saf94

There are some ‘methods’ already known to JavaScript, map being one of them. Once you master functions and objects in JavaScript this will make more sense but for the time being try to hang in there.

Methods (a method is a ‘special’ kind of function :slight_smile: ) or indeed functions can be passed parameters. In your example map is accepting an anonymous function (the function doesn’t have a name) as a parameter. It then runs what is inside the function, which in this case is the passed value(val) times four. Map is the method that, you guessed it…maps, each value from the original old array that then in turn is multiplied by four.

Finally I would recommend reading through this short explanation on functions. http://www.w3schools.com/js/js_function_parameters.asp

Good luck and have fun! :smiley:

1 Like