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

Version Path
trackler-2.2.1.159 tracks/javascript/exercises/bob/example.js
trackler-2.2.1.158 tracks/javascript/exercises/bob/example.js
trackler-2.2.1.157 tracks/javascript/exercises/bob/example.js
trackler-2.2.1.156 tracks/javascript/exercises/bob/example.js
trackler-2.2.1.155 tracks/javascript/exercises/bob/example.js
trackler-2.2.1.154 tracks/javascript/exercises/bob/example.js
trackler-2.2.1.153 tracks/javascript/exercises/bob/example.js
trackler-2.2.1.152 tracks/javascript/exercises/bob/example.js
trackler-2.2.1.151 tracks/javascript/exercises/bob/example.js
trackler-2.2.1.150 tracks/javascript/exercises/bob/example.js
trackler-2.2.1.149 tracks/javascript/exercises/bob/example.js
trackler-2.2.1.148 tracks/javascript/exercises/bob/example.js
trackler-2.2.1.147 tracks/javascript/exercises/bob/example.js
trackler-2.2.1.146 tracks/javascript/exercises/bob/example.js
trackler-2.2.1.145 tracks/javascript/exercises/bob/example.js
trackler-2.2.1.144 tracks/javascript/exercises/bob/example.js
trackler-2.2.1.143 tracks/javascript/exercises/bob/example.js
trackler-2.2.1.142 tracks/javascript/exercises/bob/example.js
trackler-2.2.1.141 tracks/javascript/exercises/bob/example.js
trackler-2.2.1.140 tracks/javascript/exercises/bob/example.js