UNPKG

sb-game

Version:
38 lines (28 loc) 3.6 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _ = _interopRequireDefault(require("..")); var _utils = require("../utils"); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } const gameConditions = 'What number is missing in the progression?'; const lengthProgression = 10; const getGameData = () => { const indexHiddenNumber = (0, _utils.getRandom)(0, lengthProgression - 1); const stepProgression = (0, _utils.getRandom)(2, 15); const firstElement = (0, _utils.getRandom)(1, 25); let progression = ''; for (let i = 0; i < lengthProgression; i += 1) { const nextElement = i === indexHiddenNumber ? '.. ' : `${firstElement + i * stepProgression} `; progression = `${progression}${nextElement}`; } const question = progression; const answer = String(firstElement + indexHiddenNumber * stepProgression); return (0, _utils.cons)(question, answer); }; var _default = () => { (0, _.default)(gameConditions, getGameData); }; exports.default = _default; //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9nYW1lcy9wcm9ncmVzc2lvbi5qcyJdLCJuYW1lcyI6WyJnYW1lQ29uZGl0aW9ucyIsImxlbmd0aFByb2dyZXNzaW9uIiwiZ2V0R2FtZURhdGEiLCJpbmRleEhpZGRlbk51bWJlciIsInN0ZXBQcm9ncmVzc2lvbiIsImZpcnN0RWxlbWVudCIsInByb2dyZXNzaW9uIiwiaSIsIm5leHRFbGVtZW50IiwicXVlc3Rpb24iLCJhbnN3ZXIiLCJTdHJpbmciXSwibWFwcGluZ3MiOiI7Ozs7Ozs7QUFBQTs7QUFDQTs7OztBQUVBLE1BQU1BLGNBQWMsR0FBRyw0Q0FBdkI7QUFFQSxNQUFNQyxpQkFBaUIsR0FBRyxFQUExQjs7QUFFQSxNQUFNQyxXQUFXLEdBQUcsTUFBTTtBQUN4QixRQUFNQyxpQkFBaUIsR0FBRyxzQkFBVSxDQUFWLEVBQWFGLGlCQUFpQixHQUFHLENBQWpDLENBQTFCO0FBQ0EsUUFBT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