javascript exercism.io bob solution
var Bob = function() {
return {
hey: function(input) {
// Remove leading or trailing spaces just in case.
input = input.trim();
// Check for silence (empty string or spaces which would be removed by trim above).
if (input === '') {
return 'Fine. Be that way!';
}
// Regular expression to test if there are any letter (alphabetic) characters
// in input string. (Regex excludes non-alpha characters.)
regex = /[^\W\d_]+/g;
// Test for alpha characters and SHOUTING.
if (regex.test(input) && input === input.toUpperCase()) {
return 'Whoa, chill out!';
}
// Check for a question.
if (input.charAt(input.length-1) === '?') {
return 'Sure.';
}
// All other cases:
return 'Whatever.';
}
};
};
module.exports = Bob;
Also in JavaScript:
- cache buster in angular application
- javascript display block
- jquery select2 multiple select all
- Add object to array javascript
- javascript number format
- angular for each
- javascript response redirect
- javascript get random array of integre in given range
- javascript iterate through a binary tree
- javascript foreach object key
- display amount with currency for jquery
- setting property to method in child class javascript
- how to validate an email address in javascript
- how to call a function in react with arguments onclick
- Javascript measure function run time
- ajax stand for
- how to right plain text format file in node js
- angular injector.create example
- how to add oAuth google signin in react native app
- span change jquery
- reset parsley validation
- array methods in javascript
- enable disable click on div jquery
- how to make a scrollable list component in react js