Deim-Sha/frontend-project-lvl1

View on GitHub
src/games/even.js

Summary

Maintainability
A
35 mins
Test Coverage
import { cons } from 'hexlet-pairs';
import playGame from '..';
import getRandomInteger from '../utils';

const ruleEven = 'Answer "yes" if the number is even, otherwise answer "no".';

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

const createQuestionAnswer = () => {
  const question = getRandomInteger();
  const correctAnswer = isEven(question) ? 'yes' : 'no';
  return cons(question, correctAnswer);
};

export default () => playGame(ruleEven, createQuestionAnswer);