Simplify clozeBuild

This commit is contained in:
toasted-nutbread 2019-11-26 10:53:21 -05:00
parent afddec66eb
commit 3a7ef6c560

View File

@ -633,18 +633,13 @@ class Display {
return index >= 0 && index < entries.length ? entries[index] : null;
}
static clozeBuild(sentence, source) {
const result = {
sentence: sentence.text.trim()
static clozeBuild({text, offset}, source) {
return {
sentence: text.trim(),
prefix: text.substring(0, offset).trim(),
body: text.substring(offset, offset + source.length),
suffix: text.substring(offset + source.length).trim()
};
if (source) {
result.prefix = sentence.text.substring(0, sentence.offset).trim();
result.body = sentence.text.substring(sentence.offset, sentence.offset + source.length);
result.suffix = sentence.text.substring(sentence.offset + source.length).trim();
}
return result;
}
entryIndexFind(element) {