DEV Community

Discussion on: JavaScript Map() Method Explained by Going On a Hike

Collapse
 
jishvi profile image
Jishnu Vasanth • Edited

Example #1

let startHike= [96, 84, 92, 98, 94]; 
let summit = startHike.map(hikerEnergy=>hikerEnergy / 2); 

Example #2

let startHike= [
     {name:"dave", water: 86},
     {name:"andrea", water: 56},
     {name:"maria", water: 42},
     {name:"nico", water: 60},
     {name:"will", water: 36} 
    ]; 
let summit = startHike.map(hikerEnergy => hikerEnergy['water']);

More concisely with arrow function.

Collapse
 
kamui62552688 profile image
Kamui

I found for some reason arrow function less readable

Collapse
 
chizom_ profile image
Chizom Echehieuka

I find it very readable and clean. At first it didnt make any sense until I read about it on eloquentjavascript.net/03_function...

It made a lot of sense after that.

Collapse
 
kbk0125 profile image
Kevin Kononenko

Good call, Jishnu. It is always hard for me to tell when I write whether the audience will know about arrow functions. In the dev.to community, people probably do!