marksaponenko/project-lvl1-s98

View on GitHub
src/games/prime.js

Summary

Maintainability
A
0 mins
Test Coverage
import startChallenge from '..';
import { getRandomNumber, isPrime, makePair } from '../helpers';

const getPairQuestionAnswer = () => {
  const question = getRandomNumber(100);
  const answer = isPrime(question) ? 'yes' : 'no';
  return makePair(question, answer);
};

const gameDescription = 'Answer "yes" if number is prime otherwise answer "no".';
const startGame = () => startChallenge(getPairQuestionAnswer, gameDescription);

export default startGame;