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.0.4 tracks/javascript/exercises/bob/example.js
trackler-2.2.0.3 tracks/javascript/exercises/bob/example.js
trackler-2.2.0.2 tracks/javascript/exercises/bob/example.js
trackler-2.2.0.1 tracks/javascript/exercises/bob/example.js
trackler-2.2.0.0 tracks/javascript/exercises/bob/example.js
trackler-2.1.0.55 tracks/javascript/exercises/bob/example.js
trackler-2.1.0.54 tracks/javascript/exercises/bob/example.js