function solution(k, arr) {
let p = 0,
q = 0,
sum = 0,
answer = 0;
for (q; q < arr.length; q++) {
sum += arr[q];
answer = Math.max(answer, sum);
if (q - p === k - 1) {
p++;
q = p - 1;
sum = 0;
}
}
return answer;
}
let a = [12, 15, 11, 20, 25, 10, 20, 19, 13, 15];
console.log(solution(3, a));