From 713d599f06e0add448df3f877bcdee16e4ae66be Mon Sep 17 00:00:00 2001 From: Isabelle Viktoria Maciohsek Date: Mon, 19 Oct 2020 18:52:11 +0300 Subject: [PATCH] Update flip --- snippets/flip.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/snippets/flip.md b/snippets/flip.md index 9afd53b03..ff6adf830 100644 --- a/snippets/flip.md +++ b/snippets/flip.md @@ -3,9 +3,10 @@ title: flip tags: function,intermediate --- -Flip takes a function as an argument, then makes the first argument the last. +Takes a function as an argument, then makes the first argument the last. -- Return a closure that takes variadic inputs, and splices the last argument to make it the first argument before applying the rest. +- Use argument destructuring and a closure with variadic arguments. +- Splice the first argument, using the spread operator (`...`), to make it the last before applying the rest. ```js const flip = fn => (first, ...rest) => fn(...rest, first);