File tree 3 files changed +37
-0
lines changed
solution/1800-1899/1812.Determine Color of a Chessboard Square
3 files changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -82,6 +82,20 @@ class Solution {
82
82
}
83
83
```
84
84
85
+ ### ** JavaScript**
86
+
87
+ ``` js
88
+ /**
89
+ * @param {string} coordinates
90
+ * @return {boolean}
91
+ */
92
+ var squareIsWhite = function (coordinates ) {
93
+ let x = coordinates .charAt (0 ).charCodeAt () - ' a' .charCodeAt () + 1 ;
94
+ let y = Number (coordinates .charAt (1 ));
95
+ return ((x + y) & 1 ) == 1 ;
96
+ };
97
+ ```
98
+
85
99
### ** ...**
86
100
87
101
```
Original file line number Diff line number Diff line change @@ -72,6 +72,20 @@ class Solution {
72
72
}
73
73
```
74
74
75
+ ### ** JavaScript**
76
+
77
+ ``` js
78
+ /**
79
+ * @param {string} coordinates
80
+ * @return {boolean}
81
+ */
82
+ var squareIsWhite = function (coordinates ) {
83
+ let x = coordinates .charAt (0 ).charCodeAt () - ' a' .charCodeAt () + 1 ;
84
+ let y = Number (coordinates .charAt (1 ));
85
+ return ((x + y) & 1 ) == 1 ;
86
+ };
87
+ ```
88
+
75
89
### ** ...**
76
90
77
91
```
Original file line number Diff line number Diff line change
1
+ /**
2
+ * @param {string } coordinates
3
+ * @return {boolean }
4
+ */
5
+ var squareIsWhite = function ( coordinates ) {
6
+ let x = coordinates . charAt ( 0 ) . charCodeAt ( ) - 'a' . charCodeAt ( ) + 1 ;
7
+ let y = Number ( coordinates . charAt ( 1 ) ) ;
8
+ return ( ( x + y ) & 1 ) == 1 ;
9
+ } ;
You can’t perform that action at this time.
0 commit comments