diff options
author | terminaldweller <devi@terminaldweller.com> | 2024-01-05 19:27:17 +0000 |
---|---|---|
committer | terminaldweller <devi@terminaldweller.com> | 2024-01-05 19:27:17 +0000 |
commit | 2e4f1dea40966b93edfc1ceb36d3cfdb1fc67a3e (patch) | |
tree | 1785d42de06aebee372223309b10f1345138b1ea /2634 | |
parent | 2870 (diff) | |
download | leetcode-2e4f1dea40966b93edfc1ceb36d3cfdb1fc67a3e.tar.gz leetcode-2e4f1dea40966b93edfc1ceb36d3cfdb1fc67a3e.zip |
2634
Diffstat (limited to '')
-rw-r--r-- | 2634/main.js | 17 |
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; +}; |