remove unused variable, pass through numerals

This commit is contained in:
Dsm4ck 2017-01-27 18:06:33 -05:00
parent ea1b020651
commit a5a4bfc79d

View file

@ -3,18 +3,25 @@
var words, inputElement, outputElement; var words, inputElement, outputElement;
function translate(input) { function translate(input) {
var i, length, output, key, a = 'a'.charCodeAt(0), z = 'z'.charCodeAt(0); var i, length, output, key, numKey, a = 'a'.charCodeAt(0), zero = '0'.charCodeAt(0);
input = input.toLowerCase(); input = input.toLowerCase();
output = ""; output = "";
length = input.length; length = input.length;
for (i = 0; i < length; i += 1) { for (i = 0; i < length; i += 1) {
key = input.charCodeAt(i) - a; key = input.charCodeAt(i) - a;
numKey = input.charCodeAt(i) - zero;
if (key >= 0 && key <= 26) { if (key >= 0 && key <= 26) {
if (i > 0) { if (i > 0) {
output += " "; output += " ";
} }
output += words[key]; output += words[key];
} }
else if(numKey >= 0 && numKey <= 10){
if (i > 0) {
output += " ";
}
output += numKey.toString();
}
} }
return output; return output;
} }