Clear, Simple, and Powerful Solution Anyone Can Grasp
Code


# Code
```javascript []
/**
 * @param {number[]} nums
 * @param {number} k
 * @return {number}
 */
var sumOfGoodNumbers = function (nums, k) {
    let sum = 0;

    for (let i = 0; i < nums.length; i++) {
        let leftValid = (i - k) >= 0 ? nums[i] > nums[i - k] : true;
        let rightValid = (i + k) < nums.length ? nums[i] > nums[i + k] : true;

        if (leftValid && rightValid) {
            sum += nums[i];
        }
    }

    return sum;
};
```
['JavaScript']