Sha256: a9c04e1afc766df5df11a53923ae18e594f1a6712231b7d7b86f8292a0e6be73

Contents?: true

Size: 649 Bytes

Versions: 47

Compression:

Stored size: 649 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)) {
      return 'Whoa, chill out!';
    } else if (isAQuestion(message)) {
      return 'Sure.';
    } else {
      return 'Whatever.';
    }
  };
}

module.exports = Bob;

Version data entries

47 entries across 47 versions & 1 rubygems

Version Path
trackler-2.2.1.17 tracks/javascript/exercises/bob/example.js
trackler-2.2.1.16 tracks/javascript/exercises/bob/example.js
trackler-2.2.1.15 tracks/javascript/exercises/bob/example.js
trackler-2.2.1.14 tracks/javascript/exercises/bob/example.js
trackler-2.2.1.13 tracks/javascript/exercises/bob/example.js
trackler-2.2.1.12 tracks/javascript/exercises/bob/example.js
trackler-2.2.1.11 tracks/javascript/exercises/bob/example.js
trackler-2.2.1.10 tracks/javascript/exercises/bob/example.js
trackler-2.2.1.9 tracks/javascript/exercises/bob/example.js
trackler-2.2.1.8 tracks/javascript/exercises/bob/example.js
trackler-2.2.1.7 tracks/javascript/exercises/bob/example.js
trackler-2.2.1.6 tracks/javascript/exercises/bob/example.js
trackler-2.2.1.5 tracks/javascript/exercises/bob/example.js
trackler-2.2.1.4 tracks/javascript/exercises/bob/example.js
trackler-2.2.1.3 tracks/javascript/exercises/bob/example.js
trackler-2.2.1.2 tracks/javascript/exercises/bob/example.js
trackler-2.2.1.1 tracks/javascript/exercises/bob/example.js
trackler-2.2.1.0 tracks/javascript/exercises/bob/example.js
trackler-2.2.0.6 tracks/javascript/exercises/bob/example.js
trackler-2.2.0.5 tracks/javascript/exercises/bob/example.js