Skip to content

Commit

Permalink
code factorization
Browse files Browse the repository at this point in the history
  • Loading branch information
fabi1cazenave committed Feb 15, 2024
1 parent be9f918 commit 1e97ae4
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions js/dactylo.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,16 +111,12 @@ window.addEventListener('DOMContentLoaded', () => {
const lessonFilter = word =>
Array.from(word).every(letter => lessonLetters.indexOf(letter) >= 0);

// gLessonLevel = level;
gLessonWords = gDictionary.words.filter(lessonFilter);
if (gLessonWords.length < MIN_WORD_COUNT) {
gLessonWords = gLessonWords.concat(gDictionary.trigrams.filter(lessonFilter));
}
if (gLessonWords.length < MIN_WORD_COUNT) {
gLessonWords = gLessonWords.concat(gDictionary.bigrams.filter(lessonFilter));
}
if (gLessonWords.length < MIN_WORD_COUNT) {
gLessonWords = gLessonWords.concat(rawLetters);
gLessonWords = [];
for (dict of [gDictionary.words, gDictionary.trigrams, gDictionary.bigrams, rawLetters]) {
gLessonWords = gLessonWords.concat(dict.filter(lessonFilter));
if (gLessonWords.length > MIN_WORD_COUNT) {
break;
}
}

showLesson();
Expand Down

0 comments on commit 1e97ae4

Please sign in to comment.