From 024291e7bc328301332e7aed9f8de4f2f2a53bd9 Mon Sep 17 00:00:00 2001 From: gkucmierz Date: Sun, 17 Sep 2017 19:48:49 +0200 Subject: [PATCH] Which are in? --- which-are-in/index.js | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 which-are-in/index.js diff --git a/which-are-in/index.js b/which-are-in/index.js new file mode 100644 index 0000000..68c8dce --- /dev/null +++ b/which-are-in/index.js @@ -0,0 +1,6 @@ +// https://www.codewars.com/kata/which-are-in/train/javascript + +function inArray(a1, a2) { + let s2 = a2.join('_'); + return a1.filter(w => 0 <= s2.indexOf(w)).sort((a, b) => a.localeCompare(b)); +} \ No newline at end of file