From a44f2b8f57a66dbe245ea0142692dae5ce59acf4 Mon Sep 17 00:00:00 2001 From: Enzo Volkmann Date: Sun, 7 Jan 2018 23:08:48 +0100 Subject: [PATCH] Update longestString() --- snippets/longestString.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/snippets/longestString.md b/snippets/longestString.md index c8d02ca4d..03539dbe2 100644 --- a/snippets/longestString.md +++ b/snippets/longestString.md @@ -1,9 +1,10 @@ ### longestString -Takes an array of strings and returns the longestString one. +Takes an array of strings and returns the longest one. Uses the [rest operator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/rest_parameters) to handle arrays as well as an indefinite amount of single arguments. +Strings are compared using `Array.reduce()`. ```js const longestString = (...strings) => [...strings].reduce((a, b) => a.length > b.length ? a : b);