@kyi193/kevins-thought-machine
Version:
Randomly return an answer for a yes or no question
59 lines (47 loc) • 2.22 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
var OnThisMonthResponse = /*#__PURE__*/function () {
function OnThisMonthResponse() {
_classCallCheck(this, OnThisMonthResponse);
this.months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
this.when = ['before', 'after'];
this.randomMonth;
this.randomWhen;
}
_createClass(OnThisMonthResponse, [{
key: "getAnswer",
value: function getAnswer() {
var randomMonthIdx = Math.floor(Math.random() * this.months.length);
var randomWhenIdx = Math.floor(Math.random() * this.when.length);
var randomMonth = this.months[randomMonthIdx];
var randomWhen = this.when[randomWhenIdx];
this.randomMonth = randomMonth;
this.randomWhen = randomWhen;
if (randomMonth === 'January' && randomWhen === 'before') {
this.randomWhen = 'after';
}
if (randomMonth === 'December' && randomWhen === 'after') {
this.randomWhen = 'before';
}
return "If you were born ".concat(randomWhen, " the month of ").concat(randomMonth, ", then yes");
}
}, {
key: "getResults",
value: function getResults() {
return {
answer: this.getAnswer(),
index: 6,
randomWhen: this.randomWhen,
randomMonth: this.randomMonth
};
}
}]);
return OnThisMonthResponse;
}();
exports["default"] = OnThisMonthResponse;