Skip to content

Instantly share code, notes, and snippets.

@sethschori
Last active July 31, 2016 19:04
Show Gist options
  • Save sethschori/1203b13181e663f782fb3c879d0aeb4c to your computer and use it in GitHub Desktop.
Save sethschori/1203b13181e663f782fb3c879d0aeb4c to your computer and use it in GitHub Desktop.
//Complete properNounFilter()
// The function should return true if the word argument is a proper Noun (first letter is capitalized). It should return false if the word isn't a proper Noun, if the word is mixed case or if it is all caps
var properNounFilter = function(word) {
var firstLetter = word.slice(0,1);
var remainder = word.slice(1);
if (firstLetter.toUpperCase() === firstLetter && remainder.toLowerCase() === remainder) return true;
return false;
}
//Tests
console.log("this should be false: " + properNounFilter('euphoria'));
console.log("this should be true: " + properNounFilter('Einstein'));
console.log("this should be true: " + properNounFilter('Nebraska'));
console.log("this should be false: " + properNounFilter('ZOMGLOL'));
console.log("this should be false: " + properNounFilter('apOLLo'));
Native Browser JavaScript
this should be false: false
this should be true: true
this should be true: true
this should be false: false
this should be false: false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment