UNPKG

@kyi193/kevins-thought-machine

Version:

Randomly return an answer for a yes or no question

44 lines (35 loc) 1.68 kB
"use strict"; 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 IfNameStartsWithResponse = /*#__PURE__*/function () { function IfNameStartsWithResponse() { _classCallCheck(this, IfNameStartsWithResponse); this.alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; this.randomLetter; } _createClass(IfNameStartsWithResponse, [{ key: "getAnswer", value: function getAnswer() { var randomLetterIdx = Math.floor(Math.random() * this.alphabet.length); var randomLetter = this.alphabet[randomLetterIdx]; this.randomLetter = randomLetter; return "If your name starts with a ".concat(randomLetter, " then sadly no"); } }, { key: "getResults", value: function getResults() { return { answer: this.getAnswer(), index: 7, randomLetter: this.randomLetter }; } }]); return IfNameStartsWithResponse; }(); exports["default"] = IfNameStartsWithResponse;