aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorterminaldweller <devi@terminaldweller.com>2024-01-05 19:27:17 +0000
committerterminaldweller <devi@terminaldweller.com>2024-01-05 19:27:17 +0000
commit2e4f1dea40966b93edfc1ceb36d3cfdb1fc67a3e (patch)
tree1785d42de06aebee372223309b10f1345138b1ea
parent2870 (diff)
downloadleetcode-2e4f1dea40966b93edfc1ceb36d3cfdb1fc67a3e.tar.gz
leetcode-2e4f1dea40966b93edfc1ceb36d3cfdb1fc67a3e.zip
2634
-rw-r--r--2634/main.js17
1 files changed, 17 insertions, 0 deletions
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;
+};