anka1928/project-lvl1-s284

View on GitHub
src/games/even.js

Summary

Maintainability
A
0 mins
Test Coverage
import { cons } from 'hexlet-pairs';
import gameFlow from '..';
import getRandom from '../utils';

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

const rightAnswer = num => (isEven(num) ? 'yes' : 'no');

const questionAndAnswer = () => {
  const question = getRandom(1, 99);
  const correctAnswer = rightAnswer(question);
  return cons(question, correctAnswer);
};

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

const game = () => {
  gameFlow(description, questionAndAnswer);
};
export default game;