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.180 tracks/javascript/exercises/bob/example.js
trackler-2.2.1.179 tracks/javascript/exercises/bob/example.js
trackler-2.2.1.178 tracks/javascript/exercises/bob/example.js
trackler-2.2.1.177 tracks/javascript/exercises/bob/example.js
trackler-2.2.1.176 tracks/javascript/exercises/bob/example.js
trackler-2.2.1.175 tracks/javascript/exercises/bob/example.js
trackler-2.2.1.174 tracks/javascript/exercises/bob/example.js
trackler-2.2.1.173 tracks/javascript/exercises/bob/example.js
trackler-2.2.1.172 tracks/javascript/exercises/bob/example.js
trackler-2.2.1.171 tracks/javascript/exercises/bob/example.js
trackler-2.2.1.170 tracks/javascript/exercises/bob/example.js
trackler-2.2.1.169 tracks/javascript/exercises/bob/example.js
trackler-2.2.1.167 tracks/javascript/exercises/bob/example.js
trackler-2.2.1.166 tracks/javascript/exercises/bob/example.js
trackler-2.2.1.165 tracks/javascript/exercises/bob/example.js
trackler-2.2.1.164 tracks/javascript/exercises/bob/example.js
trackler-2.2.1.163 tracks/javascript/exercises/bob/example.js
trackler-2.2.1.162 tracks/javascript/exercises/bob/example.js
trackler-2.2.1.161 tracks/javascript/exercises/bob/example.js
trackler-2.2.1.160 tracks/javascript/exercises/bob/example.js