From ae3d577f6f50951b56648acb45e8e462ab2e0afa Mon Sep 17 00:00:00 2001 From: Angelos Chalaris Date: Wed, 13 May 2020 13:36:36 +0300 Subject: [PATCH] Add binary --- snippets/binary.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 snippets/binary.md diff --git a/snippets/binary.md b/snippets/binary.md new file mode 100644 index 000000000..3cd327e0e --- /dev/null +++ b/snippets/binary.md @@ -0,0 +1,16 @@ +--- +title: binary +tags: function,beginner +--- + +Creates a function that accepts up to two arguments, ignoring any additional arguments. + +Call the provided function, `fn`, with the first two arguments given. + +```js +const binary = fn => (a, b) => fn(a, b); +``` + +```js +['2', '1', '0'].map(binary(Math.max)); // [2, 1, 2] +```