From 5fa109df640df19e86f67d9c13aa591a0c2fbaff Mon Sep 17 00:00:00 2001 From: Matthew Belongia Date: Fri, 6 May 2016 17:06:15 -0400 Subject: [PATCH 1/2] first commit --- index.html | 7 ++++-- morseCode.js | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+), 2 deletions(-) create mode 100644 morseCode.js diff --git a/index.html b/index.html index ff498cf..c227136 100644 --- a/index.html +++ b/index.html @@ -23,7 +23,10 @@

Instructions

Translation

- - +
+ + diff --git a/morseCode.js b/morseCode.js new file mode 100644 index 0000000..713a546 --- /dev/null +++ b/morseCode.js @@ -0,0 +1,69 @@ +var reply; +var translatedReply; +var spacedOut; + +var display = document.getElementById("result"); + +var morse = { + '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' : '--..', + '1' : '.----', + '2' : '..---', + '3' : '...--', + '4' : '....-', + '5' : '.....', + '6' : '-....', + '7' : '--...', + '8' : '---..', + '9' : '----.', + '0' : '-----', + '.' : '.-.-.-', + ',' : '--..--', + '?' : '..--..', + '/' : '-..-.', + ' ' : '|' +}; + +function prompter(){ + reply = prompt("What text do you want translated?"); +} + +function translate(spacedOut){ + return morse[spacedOut]; +} + +function printTranslate(){ + spacedOut = reply.split("").map(translate).join(" "); + display.innerHTML = spacedOut; + +} + +prompter(); +printTranslate(); +console.log(reply); +console.log(spacedOut); + From c31acbf7899344424474608869ef7188c68e7f51 Mon Sep 17 00:00:00 2001 From: Matthew Belongia Date: Fri, 6 May 2016 17:11:53 -0400 Subject: [PATCH 2/2] added toLowerCase() --- morseCode.js | 1 + 1 file changed, 1 insertion(+) diff --git a/morseCode.js b/morseCode.js index 713a546..ceb869f 100644 --- a/morseCode.js +++ b/morseCode.js @@ -50,6 +50,7 @@ var morse = { function prompter(){ reply = prompt("What text do you want translated?"); + reply = reply.toLowerCase(); } function translate(spacedOut){