From 07ddbb398df3c7cd015aa1eeb74e5643badcde7a Mon Sep 17 00:00:00 2001 From: SbDove <100377552+SbDove@users.noreply.github.com> Date: Tue, 8 Oct 2024 16:08:11 -0700 Subject: [PATCH] Remove replaceAll --- src/common.js | 21 +++++++++++++-------- src/event-handler.js | 1 - 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/common.js b/src/common.js index 4f4da62..f7bbee4 100644 --- a/src/common.js +++ b/src/common.js @@ -51,9 +51,7 @@ Common.prototype.normalizeEmail = function(email) { return email; } - charactersToRemove.forEach(function(character) { - parts[0] = parts[0].replaceAll(character, '').toLowerCase(); - }) + parts[0]= replace(parts[0], charactersToRemove); return parts.join('@'); } @@ -61,11 +59,18 @@ Common.prototype.normalizeEmail = function(email) { Common.prototype.normalizePhone = function(phone) { var charactersToRemove = [' ', '-', '(', ')'] - charactersToRemove.forEach(function(character) { - phone = phone.replaceAll(character, ''); - }) - - return phone; + return replace(phone, charactersToRemove); } +function replace(string, targets) { + debugger; + var newString = ''; + for(var i = 0; i < string.length; i++){ + var char = string[i]; + if (!targets.includes(char)){ + newString += char + } + } + return newString.toLowerCase(); +} module.exports = Common; diff --git a/src/event-handler.js b/src/event-handler.js index 484eca3..e6cb645 100644 --- a/src/event-handler.js +++ b/src/event-handler.js @@ -17,7 +17,6 @@ function EventHandler(common) { this.common = common || {}; } EventHandler.prototype.logEvent = function() {}; - EventHandler.prototype.logError = function() { // The schema for a logError event is the same, but noteworthy differences are as follows: // {