From 002fd4fa7934387d65a10a2d6bdd2207d219f714 Mon Sep 17 00:00:00 2001 From: Angelos Chalaris Date: Tue, 12 Dec 2017 16:09:44 +0200 Subject: [PATCH] Build README Also shorten syntax in objects from key-value pairs. --- README.md | 2 +- snippets/object-from-key-value-pairs.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8e718d097..2c6e2082c 100644 --- a/README.md +++ b/README.md @@ -283,7 +283,7 @@ const timeTaken = (f,...args) => { Use `Array.reduce()` to create and combine key-value pairs. ```js -const objectFromPairs = arr => arr => arr.reduce((a,b) => { a[b[0]] = b[1]; return a;}, {}); +const objectFromPairs = arr => arr => arr.reduce((a,b) => (a[b[0]] = b[1], a), {}); ``` ### Powerset diff --git a/snippets/object-from-key-value-pairs.md b/snippets/object-from-key-value-pairs.md index 0435b4c4d..90f41802c 100644 --- a/snippets/object-from-key-value-pairs.md +++ b/snippets/object-from-key-value-pairs.md @@ -3,5 +3,5 @@ Use `Array.reduce()` to create and combine key-value pairs. ```js -const objectFromPairs = arr => arr => arr.reduce((a,b) => { a[b[0]] = b[1]; return a;}, {}); +const objectFromPairs = arr => arr => arr.reduce((a,b) => (a[b[0]] = b[1], a), {}); ```