I am trying to update a string to its corresponding values with two arrays
Here is the set up
An array of english characters with corresponding leet characters
let letters = [ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' ];
let leetChars = ['@', '8', '(', '|)', '3', 'ph', 'g', '#','l', '_|', '|<', '1', "|'|'|", '/\/', '0', '|D', '(,)', '|2', '5', '+', '|_|', '|/', "|/|/'",'><', 'j', '2'];
Given a string I want to be able to return a new string containing the corresponding leet characters of the given original string.
for example 'Multiverse' should be "|'|'||_|1+l|/3|253"
My Approach
I have created a function leetTranslator that accepts a a string(of normal characters) as a parameter.I've declared a variable translation which will hold the new string and i created a loop however i'm struggling to replace the original strings characters with the corresponding leet value.
This is what i have
function leetTranslator (str){
let translation="";
for (i=0;i<str.length;i++){
translation=str.replace(/str/gi , letters );
}
return translation ;
}