vladalexeev-git/frontend-project-lvl1

View on GitHub
src/games/even.js

Summary

Maintainability
A
0 mins
Test Coverage
import { cons } from '@hexlet/pairs';
import getRandomNum from '../random.js';
import runGame from '../index.js';

const description = 'Answer "yes" if the number is even, otherwise answer "no".';
const isEven = (num) => (num % 2 === 0);

const genGameData = () => {
  const randomNum = getRandomNum(1, 100);
  const correctAnswer = isEven(randomNum) ? 'yes' : 'no';
  const question = randomNum.toString();

  return cons(question, correctAnswer);
};
export default () => runGame(genGameData, description);