/javascript/bob/bob.js

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
//
// This is only a SKELETON file for the "Bob" exercise. It's been provided as a
// convenience to get you started writing code faster.
//

var Bob = function() {};

Bob.prototype.hey = function(input) {
//
// YOUR CODE GOES HERE
  var isShouting = function(input){
    return input.toUpperCase() == input && input.toLowerCase() !== input
  }

  var isQuestion = function(input){
    return input.slice(-1) == "?"
  }

  var isBlank = function(input){
    return input == ''
  }

  if (isShouting(input)) {
    return 'Whoa, chill out!';
  }

  if (isQuestion(input)) {
    return 'Sure.'
  }

  if (isBlank(input)) {
    return 'Fine. Be that way!'
  }

  return "Whatever."
//
};

module.exports = Bob;

Comments

Is the second half of the isShouting conditional required?

trayo commented 9 April 2015 at 16:09 UTC

If I take i out, it fails.

tleskin commented 9 April 2015 at 18:06 UTC

You're not logged in right now. Please login via GitHub to comment