var brackify = (function(){ var quirkyDictionary = { "a": "(![]+[])[!![]+![]]", "b": "({}+[])[+(!+[]+!+[])]", "c": "({}+[])[+(!+[]+!+[]+!+[]+!+[]+!+[])]", "d": "([][[]]+[])[!+[]+!+[]]", "e": "(!![]+[])[!+[]+!+[]+!+[]]", "f": "(![]+[])[+[]]", "g": "([]+([]+[])[([][(![]+[])[+[]]+(![]+[]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+(![]+[]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+(![]+[]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+(![]+[]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]])[+!+[]+[!+[]+!+[]+!+[]+!+[]]]", "i": "(![]+[]+[][[]])[+!+[]+[+[]]]", "j": "({}+[])[!+[]+!+[]+!+[]]", "l": "(![]+[])[!+[]+!+[]]", "m": "((+[])[([][(![]+[])[+[]]+(![]+[]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[][(![]+[])[+[]]+(![]+[]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+([][[]]+[])[+!+[]]+(![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[+!+[]]+([][[]]+[])[+[]]+([][(![]+[])[+[]]+(![]+[]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[][(![]+[])[+[]]+(![]+[]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]+(!![]+[])[+!+[]]]+[])[+!+[]+[+!+[]]]", "n": "([][[]]+[])[+!+[]]", "o": "(!![]+[][(![]+[])[+[]]+(![]+[]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[+!+[]+[+[]]]", "r": "(!![]+[])[+!+[]]", "s": "(![]+[])[!+[]+!+[]+!+[]]", "t": "(!![]+[])[+[]]", "u": "([][[]]+[])[+[]]", "v": "(+[]+[][(![]+[])[+[]]+(![]+[]+[][[]])[+!+[]+[+[]]]+(![]+[])[!+[]+!+[]]+(!![]+[])[+[]]+(!![]+[])[!+[]+!+[]+!+[]]+(!![]+[])[+!+[]]])[!+[]+!+[]+!+[]+[+[]]]", "y": "(+[![]]+[+(+!+[]+(!+[]+[])[!+[]+!+[]+!+[]]+[+!+[]]+[+[]]+[+[]]+[+[]])])[+!+[]+[+[]]]", }; var convert = function(inputString){ //we only want characters from a-z, except the ones we have missing //i'll leave the second regex restriction apart, as it's supposed to be temporal if(/^[a-z]*/.test(inputString) && /^[^hkpwxz]+$/.test(inputString)){ var res = ""; for(var i = 0; i < inputString.length; i++){ res = res + quirkyDictionary[ inputString[i] ] +"+"; } res = res.substring(0, res.length - 1); return res; } else { return "Sorry, I don't have enough letters, but you can improve me!"; } }; return { "convertString": convert }; })(); var convertButton = document.getElementById('convertor'); convertButton.addEventListener("click", function(){ var inputBox = document.getElementById('myInput'); var textArea = document.getElementById('result'); var result = brackify.convertString(inputBox.value); textArea.value = result; });
<p><input type="text" id="myInput" /><button id="convertor">Convert to []()+!</button> <p>(Missing letters: h,k,p, w,x,z)</p> <textarea id="result"></textarea>