Skip to content

Commit 4cf9beb

Browse files
Sai Charan R Patlollaprofnandaa
authored andcommitted
feat(q1.3): another implementation for urlify (careercup#51)
* Created a new file urlify-2 with better solution * Addressed the remarks
1 parent afc0084 commit 4cf9beb

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

chapter01/1.3 - URLify/urlify-2.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
const replaceUrlSpaces = (str) => {
2+
const convertToArray = str.trim().split('');
3+
for(let i in convertToArray) {
4+
if(convertToArray[i] === " ") {
5+
convertToArray[i] = "%20"
6+
}
7+
}
8+
return convertToArray.join('');
9+
}
10+
11+
console.log(replaceUrlSpaces("Sai Charan P"));

0 commit comments

Comments
 (0)