We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 1394ddf commit c1c72afCopy full SHA for c1c72af
lcof/面试题05. 替换空格/README.md
@@ -131,12 +131,26 @@ public:
131
132
### **TypeScript**
133
134
+- 使用 `replace()`
135
+
136
```ts
137
function replaceSpace(s: string): string {
138
return s.replace(/\s/g, "%20");
139
}
140
```
141
142
+- 遍历添加
143
144
+```ts
145
+function replaceSpace(s: string): string {
146
+ const strArr = [];
147
+ for (const c of s) {
148
+ strArr.push(c === " " ? "%20" : c);
149
+ }
150
+ return strArr.join("");
151
+}
152
+```
153
154
### **...**
155
156
0 commit comments