Sha256: c57266d5de2815241484ea3017eddb15821b574228730c332563841a3525b20b

Contents?: true

Size: 619 Bytes

Versions: 208

Compression:

Stored size: 619 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(message) {
    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

208 entries across 208 versions & 1 rubygems

Version Path
trackler-1.0.3.0 tracks/javascript/exercises/bob/example.js
trackler-1.0.2.1 tracks/javascript/exercises/bob/example.js
trackler-1.0.2.0 tracks/javascript/exercises/bob/example.js
trackler-1.0.1.2 tracks/javascript/exercises/bob/example.js
trackler-1.0.1.1 tracks/javascript/exercises/bob/example.js
trackler-1.0.1.0 tracks/javascript/exercises/bob/example.js
trackler-1.0.0.1 tracks/javascript/exercises/bob/example.js
trackler-1.0.0 tracks/javascript/exercises/bob/example.js