xxphantom/backend-project-lvl1

View on GitHub
src/games/even.js

Summary

Maintainability
A
0 mins
Test Coverage
import runGameFlow from '../index.js';
import random from '../utils.js';

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

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

const getGameData = () => {
  const question = random(0, 100);
  const answer = isEven(question) ? 'yes' : 'no';
  return [question.toString(), answer];
};

export default () => {
  runGameFlow(gameTask, getGameData);
};