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:
- javascript typewriter effect
- promise javascript
- node js check type of variable
- vue current year
- random color in javascript
- kill all node server mac terminal
- nodejs open default browser on specific web page
- how to get element by attribute value in javascript
- node send file
- how to return multiple values from a function javascript
- props and state react
- how to push items in array in javascript
- number format reactjs
- required false jquery
- js get number from string
- remove first char javascript
- express multer example
- arrow function component react shortcut vscode
- react native cover image in parent view
- javascript how to pass an action back in a function
- local storage javascript
- react native layout animation
- jquery check if checkbox is not checked
- multi-dimensional array js