diff options
Diffstat (limited to '2634')
-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; +}; |