Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const square = x => x * x;
- const add = (x, y) =>x + y;
- const log = result => {
- console.log(result);
- return result;
- };
- const result = log(square(add(3,5)));
- // yields 64
- ///////////////////////// ok
- const numbers = [1,2,3];
- const result = numbers.map(n => n * 2);
- // [2,4,6]
- ///////////////////////// bad
- const numbers = [1,2,3];
- const result = numbers.map(n => { value: n});
- // [undefined], [undefined], [undefined] //BAD !!!!
- ///// /////////////////// SOLUTION
- const numbers = [1,2,3];
- const result = numbers.map(n => ({ value: n}));
- // [{value:1},{value:2},{value:3}]
Add Comment
Please, Sign In to add comment