diff --git a/chapter01/1.3 - URLify/urlify.js b/chapter01/1.3 - URLify/urlify.js index 7e993d5..6923ed0 100644 --- a/chapter01/1.3 - URLify/urlify.js +++ b/chapter01/1.3 - URLify/urlify.js @@ -13,7 +13,7 @@ var urlify = function(str, length) { strArr[pointer+1] = '2'; strArr[pointer+2] = '0'; console.log(strArr, strArr.length); - } + } pointer++; } // if character is a space, move remainder chars by two @@ -21,4 +21,26 @@ var urlify = function(str, length) { return strArr.join(''); }; -console.log(urlify('Mr John Smith ', 13), 'Mr%20John%20Smith'); +// takes 2 arguments a string and length of true strin +function URLify2(str, len) { + // setup i to be 0, use to iterate + // newStr will be use to concat character from str + let i = 0, newStr = ''; + + // while i is less than the len + while(i