brain-games-irastypain
Version:
This package is implementation of first project at Hexlet
20 lines (15 loc) • 525 B
JavaScript
import { runGame } from '..';
import { makeQA } from '../lib/qa';
import { getRandomInt, isPrime } from '../lib/math';
export default () => {
const description = 'Answer "yes" if number prime otherwise answer "no"';
const generateQA = () => {
const minNumber = 1;
const maxNumber = 1000;
const number = getRandomInt(minNumber, maxNumber);
const question = `${number}`;
const answer = isPrime(number) ? 'yes' : 'no';
return makeQA(question, answer);
};
runGame(description, generateQA);
};