update snippets 78 - 96
This commit is contained in:
committed by
Agamemnon Zorbas
parent
d0a8c3b238
commit
a7fe8cb9d6
@ -6,9 +6,10 @@ Use an anonymous inner function scope to declare an undefined memory space, usin
|
||||
|
||||
```js
|
||||
const mapObject = (arr, fn) =>
|
||||
(a => (a = [arr, arr.map(fn)], a[0].reduce((acc, val, ind) => (acc[val] = a[1][ind], acc), {})))();
|
||||
/*
|
||||
(a => (a = [arr, arr.map(fn)], a[0].reduce( (acc,val,ind) => (acc[val] = a[1][ind], acc), {}) )) ( );
|
||||
```
|
||||
|
||||
```js
|
||||
const squareIt = arr => mapObject(arr, a => a*a)
|
||||
squareIt([1,2,3]) // { 1: 1, 2: 4, 3: 9 }
|
||||
*/
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user