spanish-quizzer

An app to quiz you on Spanish vocabulary and verb conjugations
git clone https://git.ashermorgan.net/spanish-quizzer/
Log | Files | Refs | README

commit d067bd54b5ac0fafa853cee6972c4a2482482576
parent e095a87cc7b17c01aedfcff2ddd7b5a7cb304dff
Author: AsherMorgan <59518073+AsherMorgan@users.noreply.github.com>
Date:   Fri,  4 Dec 2020 10:16:48 -0800

Create quizzer shortcuts property.

Diffstat:
Mjs/quizzer.js | 23++++++++++++++---------
1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/js/quizzer.js b/js/quizzer.js @@ -30,6 +30,16 @@ let quizzer = Vue.component("quizzer", { index: this.startingIndex, responce: "", responceActive: true, + shortcuts: { + "á": /a`/g, + "é": /e`/g, + "í": /i`/g, + "ñ": /n`/g, + "ñ": /n~/g, + "ó": /o`/g, + "ú": /u`/g, + "ü": /u~/g, + }, }; }, @@ -115,17 +125,12 @@ let quizzer = Vue.component("quizzer", { Submit: function() { // Parse responce let responce = this.responce.toLowerCase(); // Make responce lowercase - responce = responce.replace(/a`/g, "á"); // Apply accented a shortcut - responce = responce.replace(/e`/g, "é"); // Apply accented e shortcut - responce = responce.replace(/i`/g, "í"); // Apply accented i shortcut - responce = responce.replace(/n`/g, "ñ"); // Apply n with tilde shortcut - responce = responce.replace(/n~/g, "ñ"); // Apply n with tilde shortcut - responce = responce.replace(/o`/g, "ó"); // Apply accented o shortcut - responce = responce.replace(/u`/g, "ú"); // Apply accented u shortcut - responce = responce.replace(/u~/g, "ü"); // Apply u with diaeresis shortcut + for (let shortcut in this.shortcuts) { + responce = responce.replace(this.shortcuts[shortcut], shortcut); + } let responces = responce.split(","); // Split string by commas for (let i = 0; i < responces.length; i++) { - responces[i] = responces[i].split(" ").filter(function(x){return x !== "";}).join(" "); // Trim whitespace + responces[i] = responces[i].trim(); // Trim whitespace } // Parse answer