RuslanFahrenheit/frontend-project-lvl1

View on GitHub
src/games/even.js

Summary

Maintainability
A
40 mins
Test Coverage
import getRandomInt from '../getRandomInt';
import { makeGame } from '../api';
import buildGame from '..';

const isEven = (n) => n % 2 === 0;
const min = 1;
const max = 100;
const description = 'Answer "yes" if number even otherwise answer "no".';

const createGameData = () => {
  const task = getRandomInt(min, max);
  const correctAnswer = isEven(task) ? 'yes' : 'no';

  return makeGame(task, correctAnswer);
};

export default () => buildGame(createGameData, description);