sergmsk/project-lvl1-s364

View on GitHub
src/games/even.js

Summary

Maintainability
A
1 hr
Test Coverage
import game from '..';
import getRandomInt from '../utils';

const minRandomNum = 1;
const maxRandomNum = 50;

const specification = 'Answer "yes" if number even otherwise answer "no".';
const isEven = n => n % 2 === 0;

const generator = () => {
  const question = getRandomInt(minRandomNum, maxRandomNum);
  const rightAnswer = isEven(question) ? 'yes' : 'no';
  return { question, rightAnswer };
};

export default () => game(specification, generator);