Using lodash countBy to simplify some repetitive code
Before
const linearQuestions = questions.filter(({type}) => type === 'linear').length;
const checkboxQuestions = questions.filter(({type}) => type === 'checkbox').length;
const radioQuestions = questions.filter(({type}) => type === 'radio').length;
After
const { linear = 0, checkbox = 0, radio = 0 } = countBy(questions, 'type');
Tweet