Almost like editorial version but in JavaScript. :). Just watch.
\n# Code\n\n/**\n * @param {number[]} nums\n * @param {number} target\n * @return {number}\n */\nvar numSubseq = function(nums, target) {\n        let n = nums.
\n# Code\n```\n/**\n * @param {number[]} nums\n * @param {number} target\n * @return {number}\n */\nvar numSubseq = function(nums, target) {\n        let n = nums.length;\n        let mod = 1_000_000_007;\n        nums.sort((a,b) => a - b);\n        \n        // Precompute the value of 2 to the power of each value.\n        let power = [];\n        power[0] = 1;\n        for (let i = 1; i < n; ++i) {\n            power[i] = (power[i - 1] * 2) % mod;\n        }\n        \n        let answer = 0;\n        let left = 0, right = n - 1;\n\n        while (left <= right) {\n            if (nums[left] + nums[right] <= target) {\n                answer += power[right - left];\n                answer %= mod;\n                left++;\n            } else {\n                right--;\n            }\n        }\n        \n        return answer;\n};\n```
['JavaScript']