[JS] Easy greedy O(n) solution
\nvar nearestValidPoint = function(x, y, points) {\n    let distance = 99999, validIndex = -1;\n    \n    for(let i in points) {\n        const [a, b] = points[
```\nvar nearestValidPoint = function(x, y, points) {\n    let distance = 99999, validIndex = -1;\n    \n    for(let i in points) {\n        const [a, b] = points[i];\n        if(a != x && b != y) continue;\n        \n        let manhattan = Math.abs(x-a) || Math.abs(y-b);\n        \n        // It is not necessary to continue if found (x,y) coordinate\n        if(manhattan === 0) return i;\n        if(manhattan < distance) [distance, validIndex] = [manhattan, i]\n    }\n    \n    return validIndex;\n};\n```
['Greedy', 'JavaScript']