diff --git a/index.html b/index.html index eb12880..8c86757 100644 --- a/index.html +++ b/index.html @@ -138,6 +138,9 @@ up a letter faster.
+
+ +

diff --git a/morse-code_files/constants.js b/morse-code_files/constants.js index be34f30..6efd9a7 100644 --- a/morse-code_files/constants.js +++ b/morse-code_files/constants.js @@ -51,6 +51,15 @@ const REVERSE_MORSE_MAP = function() { return reversed; }(); +const SYMBOLS = [ + '.', + '?', + '!', + '=', + '+', + '-' + ]; + const COMMON_WORDS = { "description": "Common English words.", "commonWords": diff --git a/morse-code_files/morse-code.js b/morse-code_files/morse-code.js index bf2fad7..23778fb 100644 --- a/morse-code_files/morse-code.js +++ b/morse-code_files/morse-code.js @@ -125,6 +125,11 @@ function convertAsciiSentenceToMorse(asciiSentence) { return splitSentence.map(convertAsciiWordToMorse); } +function getRandomSymbol() { + const randomIndex = Math.floor(Math.random() * SYMBOLS.length); + return SYMBOLS[randomIndex]; +} + function getRandomLetter() { const randomIndex = Math.floor(Math.random() * 26); return Object.keys(MORSE_MAP)[randomIndex]; @@ -231,6 +236,10 @@ function getTarget() { case 'morse-hard': target = getRandomMorseWords(); break; + case 'symbols': + target = getRandomSymbol(); + console.log(target); + break; default: target = getRandomWords(); break;