import React from "react"; import { IQuestionData } from "../types"; type Props = { question: IQuestionData; answers: any; }; export const RCheckbox = ({ question, answers }: Props) => { const result = answers.flat().reduce((acc: any, cur: any) => { acc[cur] = (acc[cur] || 0) + 1; return acc; }, {}); console.log(result); return (
{question.content.choices.map((choice: any) => (
{choice.text} - {result[choice.text] ? result[choice.text] : 0}
))}
); };