Skip to content

Commit a291a59

Browse files
committed
Create 1678. 设计 Goal 解析器.js
1 parent a707140 commit a291a59

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

1678. 设计 Goal 解析器.js

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* @param {string} command
3+
* @return {string}
4+
*/
5+
var interpret = function (command) {
6+
const result = [];
7+
for (let i = 0; i < command.length; i++) {
8+
if (command[i] === 'G') {
9+
result.push('G');
10+
} else {
11+
if (command[i + 1] === ')') {
12+
result.push('o');
13+
i += 1;
14+
} else {
15+
result.push('al');
16+
i += 3;
17+
}
18+
}
19+
}
20+
return result.join('');
21+
};

0 commit comments

Comments
 (0)