ula9/js_l1_brain_games-s12

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

Summary

Maintainability
A
0 mins
Test Coverage
// @flow

import game from '../game';

const description = 'Answer "yes" if number odd otherwise answer "no".';

const isOdd = num => num % 2 === 0;

const getQuestion = () => Math.round(Math.random() * 100);

const questionToString = (question: number) => `Question: ${question}`;

const getCorrectAnswer = (question: number) => (isOdd(question) ? 'yes' : 'no');

export default () => game(description, getQuestion, getCorrectAnswer, questionToString);