Remove the special characters from the string using javascript?

This article about get rid the special characters from the string using JavaScript. you can use this function as a global function to place this function in common file.

function removeSpecialChar(text){
    if(text) {
        var lower = text.toLowerCase();
        var upper = text.toUpperCase();
        var result = "";
        for(var i=0; i<lower.length; ++i) {
            if(isNumber(text[i]) || (lower[i] !== upper[i]) || (lower[i].trim() === '')) {
              result += text[i];
            }
        }
        return result;
    }
    return '';
}
function isNumber(text){
  if(text) {  
    var reg =  new RegExp('[0-9]+$');
    return reg.test(text);
  }
  return false;
} 

the way to call the removeSpecialChar method.

console.log(removeSpecialChar('[email protected]'))

Output:-

admintutorialwalacom