JavaScript Elegant Solution
javascript\nvar minDominoRotations = function(A, B) {\n    \n    const numSwaps = (target, X, Y) => {\n        let count = 0;\n        \n        for(let i = 0; 
```javascript\nvar minDominoRotations = function(A, B) {\n    \n    const numSwaps = (target, X, Y) => {\n        let count = 0;\n        \n        for(let i = 0; i < X.length; i++) {\n            if(target !== X[i] && target !== Y[i]) return Infinity\n            if(target !== X[i]) count++;\n        }\n        return count;\n    }\n    \n    const minSwaps = Math.min(numSwaps(A[0], A, B), numSwaps(B[0], B, A), \n                              numSwaps(A[0], B, A), numSwaps(B[0], A, B));\n    return minSwaps === Infinity ? -1 : minSwaps\n};\n```
['JavaScript']