Skip to content

Commit

Permalink
Remove replaceAll
Browse files Browse the repository at this point in the history
  • Loading branch information
SbDove committed Oct 8, 2024
1 parent b5302b7 commit 07ddbb3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
21 changes: 13 additions & 8 deletions src/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,21 +51,26 @@ 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('@');
}

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;
1 change: 0 additions & 1 deletion src/event-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -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:
// {
Expand Down

0 comments on commit 07ddbb3

Please sign in to comment.