Sha256: e6fd137463db6e1af326f6a0ae93d1dad727b17bb9728bc899df36918e2070f7
Contents?: true
Size: 729 Bytes
Versions: 49
Compression:
Stored size: 729 Bytes
Contents
function Bob() { 'use strict'; function isSilence(message) { return message.replace(/\s+/g, '') === ''; } function isShouting(message) { return message.toUpperCase() === message && /[A-Z]/.test(message); } function isAQuestion(message) { return message[message.length - 1] === '?'; } this.hey = function (input) { var message = input.trim(); if (isSilence(message)) { return 'Fine. Be that way!'; } else if (isShouting(message)) { if (isAQuestion(message)) { return "Calm down, I know what I'm doing!"; } return 'Whoa, chill out!'; } else if (isAQuestion(message)) { return 'Sure.'; } return 'Whatever.'; }; } module.exports = Bob;
Version data entries
49 entries across 49 versions & 1 rubygems