import { Trivial } from '../model/rings'; const checkTrivialAnswers = ( trivial: Trivial, answers: Map, ): number => { const { questions, info: { value }, } = trivial; const questionValue = value / questions.length; let returnValue = 0; for (let i = 0; i < questions.length; i++) { const question = questions[i]; const answer = answers.get(question.id); const correct = question.answers.find((a) => a.isCorrect); if (answer && correct && answer === correct.id) { returnValue += questionValue; } } return returnValue; }; export default checkTrivialAnswers;