tank-bohr/frontend-project-lvl1

View on GitHub
src/games/even.js

Summary

Maintainability
A
0 mins
Test Coverage
import { random } from 'lodash';
import run from '../engine';

const generateQuestion = () => {
  const number = random(1, 100);
  return {
    answer: () => {
      if ((number % 2) === 0) {
        return 'yes';
      }
      return 'no';
    },
    toString: () => String(number),
  };
};

const game = {
  hello: 'Answer "yes" if the number is even, otherwise answer "no".',
  generateQuestion,
};

export default () => run(game);