function subarraySum(num, k) {
    let counter = 0;
    let start = 0;
    let end = 0;
    let summ = nums[0];
    while (start < nums.length) {
        if (start > nums.length) {
            end = start;
            summ = nums[start];
        }
        if (summ < k) {
            end++;
            if (end === nums.length)
                break;
            summ += nums[end];
        } else if(summ > k) {
            summ -= nums[start];
            start++;
        } else {
            counter++;
            summ -= nums[start];
            start++;        
        }
    }
    return counter;
};