simplyGo/project-lvl1-s316

View on GitHub
src/games/evenGame.js

Summary

Maintainability
A
0 mins
Test Coverage
import { runGame, makeGameData } from '..';

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

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

const gameQuestion = (getRandom) => {
  const randomNum = getRandom();
  return randomNum;
};

const gameAnswer = (randomNum) => {
  const rightAnswer = isEven(randomNum) ? 'yes' : 'no';
  return rightAnswer;
};

const getGameData = () => makeGameData(gameQuestion, gameAnswer);

const evenGame = () => runGame(getGameData, gameDescription);

export default evenGame;