Easy JavaScript Solution
\nvar nearestValidPoint = function(x, y, points) {\n    let minDist = Infinity;\n    let res;\n    \n    for (let i = 0; i < points.length; i++) {\n        let 
```\nvar nearestValidPoint = function(x, y, points) {\n    let minDist = Infinity;\n    let res;\n    \n    for (let i = 0; i < points.length; i++) {\n        let [currX, currY] = points[i];\n        \n        if (currX === x || currY === y) {\n            let dist = Math.abs(x - currX) + Math.abs(y - currY);\n            if (dist < minDist) {\n                minDist = dist;\n                res = i;\n            }\n        }\n    }\n    \n    if (res === 0) return 0;\n    \n    return res ? res : -1\n};\n```
['JavaScript']