let questions = null; const loadQuestions = async ( isSearch, categories, sourceScheme, questionCount ) => { if (questions === null) { questions = await (await fetch("fizika.json")).json(); } let currentQuestions = questions.slice(); if (isSearch) { currentQuestions = currentQuestions.filter((q) => q.source.match(sourceScheme) ); } else { shuffleArray(currentQuestions); currentQuestions = currentQuestions.filter((q) => categories.includes(q.type) ); } resultHtml = ""; currentQuestions = currentQuestions.slice(0, questionCount); currentQuestions.forEach( ({ id, source, description, a, b, c, d, correct, image }, i) => { resultHtml += `

${i + 1}.

${source}

${description}
${image ? `
` : ""}



${ d ? `
` : "" }
`; } ); resultHtml += currentQuestions.length === 0 ? '
Nem található a keresésnek megfelelő feladat!
' : ``; return resultHtml; }; function shuffleArray(array) { for (let i = array.length - 1; i > 0; i--) { const j = Math.floor(Math.random() * (i + 1)); [array[i], array[j]] = [array[j], array[i]]; } }