From 2e4f1dea40966b93edfc1ceb36d3cfdb1fc67a3e Mon Sep 17 00:00:00 2001 From: terminaldweller Date: Fri, 5 Jan 2024 14:27:17 -0500 Subject: 2634 --- 2634/main.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 2634/main.js (limited to '2634') diff --git a/2634/main.js b/2634/main.js new file mode 100644 index 0000000..4d26118 --- /dev/null +++ b/2634/main.js @@ -0,0 +1,17 @@ +#!/usr/bin/env node +"use strict"; + +/** + * @param {number[]} arr + * @param {Function} fn + * @return {number[]} + */ +var filter = function (arr, fn) { + var resArr = new Array(); + for (var i = 0; i < arr.length; i++) { + if (fn(arr[i], i)) { + resArr[i].push(arr[i]); + } + } + return resArr; +}; -- cgit v1.2.3