We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f533992 commit b533d9fCopy full SHA for b533d9f
JavaScript/chapter01/1.3 - URLify/rroque98_sol.js
@@ -1,8 +1,8 @@
1
// Write a method to replace all spaces within a string with '%20'
2
3
-const URLify = (string) => string.split(' ').join('%20');
+const encodeSpaces = (string) => string.replace(/ /g, '%20');
4
5
// Tests:
6
-console.log(URLify('Hello World') === 'Hello%20World');
7
-console.log(URLify('') === '');
8
-console.log(URLify('This is an example') === 'This%20is%20an%20example');
+console.log(encodeSpaces('Hello World') === 'Hello%20World');
+console.log(encodeSpaces('') === '');
+console.log(encodeSpaces('This is an example') === 'This%20is%20an%20example');
0 commit comments