From 36f9aa873d62a23727818769ab2781c6856e67d0 Mon Sep 17 00:00:00 2001 From: Dan M Date: Fri, 27 Jan 2017 18:16:43 -0500 Subject: [PATCH] remove unused variable, pass through numerals (#2) --- main.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/main.js b/main.js index d697066..ea4eef4 100644 --- a/main.js +++ b/main.js @@ -3,18 +3,25 @@ var words, inputElement, outputElement; 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(); output = ""; length = input.length; for (i = 0; i < length; i += 1) { key = input.charCodeAt(i) - a; + numKey = input.charCodeAt(i) - zero; if (key >= 0 && key <= 26) { if (i > 0) { output += " "; } output += words[key]; } + else if(numKey >= 0 && numKey <= 10){ + if (i > 0) { + output += " "; + } + output += numKey.toString(); + } } return output; }