Skip to content

Commit

Permalink
Use less witchcraft and remove redundant type casting
Browse files Browse the repository at this point in the history
  • Loading branch information
Kuuuube committed Feb 2, 2024
1 parent 8bb9c64 commit db948ea
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions ext/js/data/sandbox/anki-note-data-creator.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,14 @@ function getFrequencyNumbers(dictionaryEntry) {
}
previousDictionary = dictionary;

const frequencyWorking = displayValue !== null ? displayValue.match(/\d+/) : frequency;
if (frequencyWorking !== null) {
frequencies.push(Number(frequencyWorking));
} else {
frequencies.push(frequency);
if (displayValue !== null) {
const frequencyMatch = displayValue.match(/\d+/);
if (frequencyMatch !== null) {
frequencies.push(Number.parseInt(frequencyMatch[0], 10));
continue;
}
}
frequencies.push(frequency);
}
return frequencies;
}
Expand Down

0 comments on commit db948ea

Please sign in to comment.