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-2.1.0.53 tracks/javascript/exercises/bob/example.js
trackler-2.1.0.52 tracks/javascript/exercises/bob/example.js
trackler-2.1.0.51 tracks/javascript/exercises/bob/example.js
trackler-2.1.0.50 tracks/javascript/exercises/bob/example.js
trackler-2.1.0.49 tracks/javascript/exercises/bob/example.js
trackler-2.1.0.48 tracks/javascript/exercises/bob/example.js
trackler-2.1.0.47 tracks/javascript/exercises/bob/example.js
trackler-2.1.0.46 tracks/javascript/exercises/bob/example.js
trackler-2.1.0.45 tracks/javascript/exercises/bob/example.js
trackler-2.1.0.44 tracks/javascript/exercises/bob/example.js
trackler-2.1.0.43 tracks/javascript/exercises/bob/example.js
trackler-2.1.0.42 tracks/javascript/exercises/bob/example.js
trackler-2.1.0.41 tracks/javascript/exercises/bob/example.js
trackler-2.1.0.40 tracks/javascript/exercises/bob/example.js
trackler-2.1.0.39 tracks/javascript/exercises/bob/example.js
trackler-2.1.0.38 tracks/javascript/exercises/bob/example.js
trackler-2.1.0.37 tracks/javascript/exercises/bob/example.js
trackler-2.1.0.36 tracks/javascript/exercises/bob/example.js
trackler-2.1.0.34 tracks/javascript/exercises/bob/example.js
trackler-2.1.0.33 tracks/javascript/exercises/bob/example.js