From 73dfb96c11d270838764eec74f9f8f6d6271a479 Mon Sep 17 00:00:00 2001 From: Siarhei Date: Fri, 19 Oct 2018 14:01:48 +0400 Subject: [PATCH 1/3] Simplify longestItem --- snippets/longestItem.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/snippets/longestItem.md b/snippets/longestItem.md index 855100d68..dd8203682 100644 --- a/snippets/longestItem.md +++ b/snippets/longestItem.md @@ -7,8 +7,8 @@ Returns `undefined` if no arguments are provided. Use `Array.prototype.reduce()`, comparing the `length` of objects to find the longest one. ```js -const longestItem = (val, ...vals) => - [val, ...vals].reduce((a, x) => (x.length > a.length ? x : a)); +const longestItem = (...vals) => + vals.reduce((a, x) => (x.length > a.length ? x : a)); ``` ```js From db2d690b2c38b71e3e4085cc6c85d4e320d1eaca Mon Sep 17 00:00:00 2001 From: Siarhei Date: Fri, 19 Oct 2018 14:05:16 +0400 Subject: [PATCH 2/3] Change argument name --- snippets/longestItem.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/snippets/longestItem.md b/snippets/longestItem.md index dd8203682..a8a7fd63e 100644 --- a/snippets/longestItem.md +++ b/snippets/longestItem.md @@ -7,8 +7,8 @@ Returns `undefined` if no arguments are provided. Use `Array.prototype.reduce()`, comparing the `length` of objects to find the longest one. ```js -const longestItem = (...vals) => - vals.reduce((a, x) => (x.length > a.length ? x : a)); +const longestItem = (...args) => + args.reduce((a, x) => (x.length > a.length ? x : a)); ``` ```js From cb6ef4f638cd8d8b0fe2d81bc4f94b2950c51054 Mon Sep 17 00:00:00 2001 From: Angelos Chalaris Date: Thu, 25 Oct 2018 13:24:26 +0300 Subject: [PATCH 3/3] Update longestItem.md --- snippets/longestItem.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/snippets/longestItem.md b/snippets/longestItem.md index a8a7fd63e..dd8203682 100644 --- a/snippets/longestItem.md +++ b/snippets/longestItem.md @@ -7,8 +7,8 @@ Returns `undefined` if no arguments are provided. Use `Array.prototype.reduce()`, comparing the `length` of objects to find the longest one. ```js -const longestItem = (...args) => - args.reduce((a, x) => (x.length > a.length ? x : a)); +const longestItem = (...vals) => + vals.reduce((a, x) => (x.length > a.length ? x : a)); ``` ```js