From 39abb855d01c71d68a76b469911eb7e4efd18a21 Mon Sep 17 00:00:00 2001 From: Marinko Malencic <97927860+mxmxmarexmxm@users.noreply.github.com> Date: Thu, 15 Jun 2023 01:28:42 +0200 Subject: [PATCH 1/3] refactor: Remove unnecessary second argument in conditional statement This commit refactors the code by removing the unnecessary second argument in the conditional statement. The condition "if (obj[str[i]] && obj[str[i]] >= 1)" has been simplified to "if (obj[str[i]])" for improved readability and code conciseness. This change helps to streamline the logic and remove unnecessary complexity from the codebase. --- chapter01/1.1 - Is Unique/isUnique.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chapter01/1.1 - Is Unique/isUnique.js b/chapter01/1.1 - Is Unique/isUnique.js index 3321571..a6ccd73 100644 --- a/chapter01/1.1 - Is Unique/isUnique.js +++ b/chapter01/1.1 - Is Unique/isUnique.js @@ -26,7 +26,7 @@ const everyCharUnique = (str, indexOffset = 'a'.charCodeAt()) => { function everyCharUnique(str) { let obj = {}; for (let i = 0; i < str.length; i++) { - if (obj[str[i]] && obj[str[i]] >= 1) { + if (obj[str[i]]) { return false; } else { obj[str[i]] = 1; From 347ede3310cfc94b79154bb10dd5701a98f7b4dd Mon Sep 17 00:00:00 2001 From: Marinko Malencic <97927860+mxmxmarexmxm@users.noreply.github.com> Date: Thu, 15 Jun 2023 02:12:31 +0200 Subject: [PATCH 2/3] Create urlify-4.js Implemented the shortest approach to URLify a string. The URLify function utilizes the trim() method to remove leading and trailing spaces and the replaceAll() method to replace spaces with '%20'. This concise solution effectively replaces all spaces in the string with the desired URL encoding. --- chapter01/1.3 - URLify/urlify-4.js | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 chapter01/1.3 - URLify/urlify-4.js diff --git a/chapter01/1.3 - URLify/urlify-4.js b/chapter01/1.3 - URLify/urlify-4.js new file mode 100644 index 0000000..4adde31 --- /dev/null +++ b/chapter01/1.3 - URLify/urlify-4.js @@ -0,0 +1,3 @@ +const URLify = (str) => { + return str.trim().replaceAll(' ', '%20'); +}; From 409d515ad29098db95ed29f58bf33f9573fcf7e8 Mon Sep 17 00:00:00 2001 From: Marinko Malencic <97927860+mxmxmarexmxm@users.noreply.github.com> Date: Thu, 15 Jun 2023 02:30:11 +0200 Subject: [PATCH 3/3] Delete urlify-4.js --- chapter01/1.3 - URLify/urlify-4.js | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 chapter01/1.3 - URLify/urlify-4.js diff --git a/chapter01/1.3 - URLify/urlify-4.js b/chapter01/1.3 - URLify/urlify-4.js deleted file mode 100644 index 4adde31..0000000 --- a/chapter01/1.3 - URLify/urlify-4.js +++ /dev/null @@ -1,3 +0,0 @@ -const URLify = (str) => { - return str.trim().replaceAll(' ', '%20'); -};