Exercism JS: Bob

Bob is a lackadaisical teenager. In conversation, his responses are very limited.

  • Bob answers ‘Sure.’ if you ask him a question.
  • He answers ‘Whoa, chill out!’ if you yell at him.
  • He says ‘Fine. Be that way!’ if you address him without actually saying anything.
  • He answers ‘Whatever.’ to anything else.

My Solution in JS:

screen-shot-2016-12-28-at-10-39-51-pm

Things to note:

  • Second part of line 11 is a clever way (that I did not come up with myself) to check if a string is alpha characters or not.  (You can also use regex to check if a string fits a certain criteria for characters.)
  • .trim() in Javascript is the same .strip in Ruby.  (They remove whitespace).
Advertisements
Exercism JS: Bob

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s