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.37 tracks/javascript/exercises/bob/example.js
trackler-2.2.1.36 tracks/javascript/exercises/bob/example.js
trackler-2.2.1.35 tracks/javascript/exercises/bob/example.js
trackler-2.2.1.34 tracks/javascript/exercises/bob/example.js
trackler-2.2.1.33 tracks/javascript/exercises/bob/example.js
trackler-2.2.1.32 tracks/javascript/exercises/bob/example.js
trackler-2.2.1.31 tracks/javascript/exercises/bob/example.js
trackler-2.2.1.30 tracks/javascript/exercises/bob/example.js
trackler-2.2.1.29 tracks/javascript/exercises/bob/example.js
trackler-2.2.1.28 tracks/javascript/exercises/bob/example.js
trackler-2.2.1.27 tracks/javascript/exercises/bob/example.js
trackler-2.2.1.26 tracks/javascript/exercises/bob/example.js
trackler-2.2.1.25 tracks/javascript/exercises/bob/example.js
trackler-2.2.1.24 tracks/javascript/exercises/bob/example.js
trackler-2.2.1.23 tracks/javascript/exercises/bob/example.js
trackler-2.2.1.22 tracks/javascript/exercises/bob/example.js
trackler-2.2.1.21 tracks/javascript/exercises/bob/example.js
trackler-2.2.1.20 tracks/javascript/exercises/bob/example.js
trackler-2.2.1.19 tracks/javascript/exercises/bob/example.js
trackler-2.2.1.18 tracks/javascript/exercises/bob/example.js