From 8787551e94ee937d5db459860ee8d2d57e0de220 Mon Sep 17 00:00:00 2001 From: Marinko Malencic <97927860+mxmxmarexmxm@users.noreply.github.com> Date: Thu, 15 Jun 2023 00:51:06 +0200 Subject: [PATCH] refactor: Rename function to ES6 arrow function and update var to let in allUniqueChars This commit renames the function to an ES6 arrow function syntax and updates the usage of var to let in the allUniqueChars function. --- chapter01/1.1 - Is Unique/isUnique.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/chapter01/1.1 - Is Unique/isUnique.js b/chapter01/1.1 - Is Unique/isUnique.js index 3321571..972387c 100644 --- a/chapter01/1.1 - Is Unique/isUnique.js +++ b/chapter01/1.1 - Is Unique/isUnique.js @@ -1,9 +1,9 @@ -var allUniqueChars = function(string) { +const allUniqueChars = (string) => { // O(n^2) approach, no additional data structures used // for each character, check remaining characters for duplicates - for (var i = 0; i < string.length; i++) { - for (var j = i + 1; j < string.length; j++) { + for (let i = 0; i < string.length; i++) { + for (let j = i + 1; j < string.length; j++) { if (string[i] === string[j]) { return false; // if match, return false }