Skip to content

Commit 825ff3c

Browse files
authored
feat: add javascript solution to lc problem: No.1812.Determine Color … (doocs#408)
1 parent a9ad038 commit 825ff3c

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

solution/1800-1899/1812.Determine Color of a Chessboard Square/README.md

+14
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,20 @@ class Solution {
8282
}
8383
```
8484

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+
8599
### **...**
86100

87101
```

solution/1800-1899/1812.Determine Color of a Chessboard Square/README_EN.md

+14
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,20 @@ class Solution {
7272
}
7373
```
7474

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+
7589
### **...**
7690

7791
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
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+
};

0 commit comments

Comments
 (0)