exercism.io bob solution
JavaScript
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:
- Title
- how to get the square root in js
- Category
- JavaScript
- Title
- javascript 2 decimal float array elements
- Category
- JavaScript
- Title
- command to create custom pipe in angular 6
- Category
- JavaScript
- Title
- find method javascript
- Category
- JavaScript
- Title
- javascript array push method
- Category
- JavaScript
- Title
- age calculator javascript
- Category
- JavaScript
- Title
- AJAX in reload a div container
- Category
- JavaScript
- Title
- event listener javascript
- Category
- JavaScript
- Title
- function in react
- Category
- JavaScript
- Title
- how get parent element javascript
- Category
- JavaScript
- Title
- how to create a new react native project
- Category
- JavaScript
- Title
- how to access router from the store vue
- Category
- JavaScript
- Title
- convert negative number to positive in javascript
- Category
- JavaScript
- Title
- create element javascript with id
- Category
- JavaScript
- Title
- javascript append element to array
- Category
- JavaScript
- Title
- difference between == and === in javascript
- Category
- JavaScript
- Title
- devextreme custom dxdatagrid field
- Category
- JavaScript
- Title
- install nodejs from ubuntu 18.04
- Category
- JavaScript
- Title
- how to write a program that tests whether it's before noon and alert “Its AM” else “its PM” in javascript
- Category
- JavaScript
- Title
- example of while loop in javascript with array length
- Category
- JavaScript
- Title
- get parent element using jquery
- Category
- JavaScript
- Title
- install node js using nvm ubuntu
- Category
- JavaScript
- Title
- grayscale image in canvas
- Category
- JavaScript
- Title
- convert milliseconds to minutes and seconds javascript
- Category
- JavaScript
- Title
- chart js title
- Category
- JavaScript
- Title
- bootstrap 4 form validator with jquery
- Category
- JavaScript
- Title
- how to check for duplicate syntax in javascript
- Category
- JavaScript
- Title
- javascript check empty property
- Category
- JavaScript
- Title
- javascript automatic click
- Category
- JavaScript
- Title
- How to get row index and cellindex together in javascript
- Category
- JavaScript
- Title
- check to see if number is a decimal javascript
- Category
- JavaScript
- Title
- Alternating Sums
- Category
- JavaScript
- Title
- how to create react app
- Category
- JavaScript
- Title
- how to check reactjs version in command prompt
- Category
- JavaScript
- Title
- clear scene\
- Category
- JavaScript
- Title
- how to deploy react app in tomcat server
- Category
- JavaScript
- Title
- angular http call caching issue even after no-cache
- Category
- JavaScript
- Title
- CSRF token in js
- Category
- JavaScript
- Title
- getting value from radio button javascript
- Category
- JavaScript
- Title
- cascading dropdown for forms react
- Category
- JavaScript
- Title
- access laravel eloquent relation in js
- Category
- JavaScript
- Title
- javascript calculator
- Category
- JavaScript
- Title
- get value from textbox in vanilla javascript
- Category
- JavaScript
- Title
- array map javascript mozilla
- Category
- JavaScript
- Title
- bookshelf insert multiple rows
- Category
- JavaScript
- Title
- axios post data vue js
- Category
- JavaScript
- Title
- how to make dynamic columns in jquery
- Category
- JavaScript
- Title
- How can I refresh a page with jQuery
- Category
- JavaScript
- Title
- integer to array javascript
- Category
- JavaScript
- Title
- javascript check if string is json parsable
- Category
- JavaScript
- Title
- angular countdown timer
- Category
- JavaScript
- Title
- document delete element
- Category
- JavaScript
- Title
- create react app scaffolding
- Category
- JavaScript
- Title
- how to change node version
- Category
- JavaScript
- Title
- how to check an empty array js
- Category
- JavaScript
- Title
- function click anywhere javascript
- Category
- JavaScript
- Title
- choose random from array javascript
- Category
- JavaScript
- Title
- angular routing url params
- Category
- JavaScript
- Title
- axios set authorization header
- Category
- JavaScript
- Title
- how to make a stopwatch using js
- Category
- JavaScript
- Title
- $pull mongoose
- Category
- JavaScript
- Title
- convert jquery to string
- Category
- JavaScript
- Title
- append to array js
- Category
- JavaScript
- Title
- disable textbox jquery
- Category
- JavaScript
- Title
- change p tag text javascript
- Category
- JavaScript
- Title
- change the value in checkbox by button react
- Category
- JavaScript
- Title
- express validator always return error
- Category
- JavaScript
- Title
- how to access all images in a document javascript
- Category
- JavaScript
- Title
- component navigation without changin the url react router
- Category
- JavaScript
- Title
- html javascript redirect
- Category
- JavaScript
- Title
- How to get the path to the file that required your module?
- Category
- JavaScript
- Title
- events in javascript
- Category
- JavaScript
- Title
- conditional rendering in react
- Category
- JavaScript
- Title
- express js
- Category
- JavaScript
- Title
- collision detection three js
- Category
- JavaScript
- Title
- how to check if object is undefined in javascript
- Category
- JavaScript
- Title
- how to set height of material ui dialog react
- Category
- JavaScript
- Title
- import npm module node.js
- Category
- JavaScript
- Title
- how to run a cloned react native project
- Category
- JavaScript
- Title
- clear the console while in strict mode
- Category
- JavaScript
- Title
- how to concatenate strings javascript
- Category
- JavaScript
- Title
- angularjs left xx characters
- Category
- JavaScript
- Title
- enable disable click on div jquery
- Category
- JavaScript
- Title
- checking if a character is an alphabet in js
- Category
- JavaScript
- Title
- javascript classes
- Category
- JavaScript
- Title
- how to check if variable is array in js
- Category
- JavaScript
- Title
- how to get textedit on mac without download
- Category
- JavaScript
- Title
- document load javascript
- Category
- JavaScript
- Title
- firestore set a document
- Category
- JavaScript
- Title
- install nuxt js
- Category
- JavaScript
- Title
- Discord embeds
- Category
- JavaScript
- Title
- inheritance in javascript
- Category
- JavaScript
- Title
- check data type in js
- Category
- JavaScript
- Title
- .innerhtml
- Category
- JavaScript
- Title
- async await javascript
- Category
- JavaScript
- Title
- javascript array sort
- Category
- JavaScript
- Title
- if clicked outside of div jquery
- Category
- JavaScript
- Title
- clone an object in javascript
- Category
- JavaScript
- Title
- ajax larave;
- Category
- JavaScript
- Title
- destructuring arrays with rest operator
- Category
- JavaScript