Add symbols category

This commit is contained in:
Nathan McRae 2024-09-02 19:35:20 -07:00
parent 3913dfa1fa
commit 03c4fb9ea9
3 changed files with 21 additions and 0 deletions

View File

@ -138,6 +138,9 @@ up a letter faster.
<br>
<input type="radio" id="difficultyVeryHard" name="difficulty" value="really-hard">
<label for="difficultyVeryHard">Very Hard (multiple words)</label>
<br>
<input type="radio" id="difficultySymbols" name="difficulty" value="symbols">
<label for="difficultySymbols">(symbols)</label>
</div>
<br>
<br>

View File

@ -51,6 +51,15 @@ const REVERSE_MORSE_MAP = function() {
return reversed;
}();
const SYMBOLS = [
'.',
'?',
'!',
'=',
'+',
'-'
];
const COMMON_WORDS = {
"description": "Common English words.",
"commonWords":

View File

@ -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;