Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var 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' ];
- var leetChars = ['@', '8', '(', '|)', '3', 'ph', 'g', '#','l', '_|', '|<', '1', "|'|'|", '/\/', '0', '|D', '(,)', '|2', '5', '+', '|_|', '|/', "|/|/'",'><', 'j', '2'];
- function translate(string) {
- // first, since all letter in array are lowercased, we will need to make our string lowercased.
- // we will need to create an empty string for the new leet word
- // next we will need to loop through each character of the string
- // for each character index, we will need to pull the letter index
- // then we will need to to pull the respective index from the leetChars array and add it to the new string
- var lowercased = string.toLowerCase();
- var leetString = '';
- var charIndex = null;
- for(var i = 0; i < lowercased.length; i++) {
- charIndex = letters.indexOf(lowercased[i]);
- leetString += leetChars[charIndex];
- }
- return leetString;
- }
- translate('Fullstack') // => 'ph|_|115+@(|<'
Add Comment
Please, Sign In to add comment