gudzii-ov/project-1-brain-games

View on GitHub
src/games/brain-prime.js

Summary

Maintainability
A
0 mins
Test Coverage
import { cons } from 'hexlet-pairs';
import { runGame } from '..';
import { getRandomInteger, isPrime } from '../common';

const gameMessage = 'Is this number prime?';

const game = () => {
  const randomNumber = getRandomInteger(0, 100);

  const question = `${randomNumber}`;

  const rightAnswer = isPrime(randomNumber) ? 'yes' : 'no';

  return cons(question, rightAnswer);
};

const brainPrime = () => runGame(gameMessage, game);

export default brainPrime;