Psixodelik/project-lvl1-s474

View on GitHub
src/games/even.js

Summary

Maintainability
A
0 mins
Test Coverage
import playGame from '..';
import getRandomNumber from '../utils';

const gameDescription = 'Answer "yes" if number even otherwise answer "no".';

const isEven = num => num % 2 === 0;

const createQuestionAndAnswer = () => {
  const question = getRandomNumber();
  const correctAnswer = isEven(question) ? 'yes' : 'no';

  return { question, correctAnswer };
};

export default () => playGame(createQuestionAndAnswer, gameDescription);