javascript - Replacing mutliple characters -
i trying write function parameter string , specific character needs replaced. give alert box converted string.
i have following code isn't working. want alert()
converted string.
function encryption(astring){ return astring.replace(/a/g, '@') .replace(/e/g, '()') .replace(/h/g, '#') .replace(/l/g,'1') .replace(/r/g,'+') .replace(/s/g.'$') .replace(/v/g,'^') .replace(/x/g,'*'); }
at first sight see typo here
.replace(/s/g.'$')
it should
.replace(/s/g,'$')
you can see working here after fixing typo
Comments
Post a Comment