Saving data fix round 2

This commit is contained in:
mrfry 2020-10-07 14:35:36 +02:00
parent 43734fb8f7
commit 1cf16dbafd
3 changed files with 8 additions and 30 deletions

View file

@ -327,7 +327,6 @@ function addQuestion(data, subj, question) {
assert(subj)
assert(question)
assert(typeof question === 'object')
let result = []
var i = 0
while (
@ -341,20 +340,14 @@ function addQuestion(data, subj, question) {
if (i < data.length) {
debugLog('Adding new question to existing subject', 'qdb add', 1)
result = [...data]
result[i].Questions = [...data[i].Questions, question]
data[i].Questions.push(question)
} else {
debugLog('Creating new subject for question', 'qdb add', 1)
result = [
...data,
{
Name: subj,
Questions: [question],
},
]
data.push({
Name: subj,
Questions: [question],
})
}
return result
}
function searchData(data, question, subjName, questionData) {