Last active
July 31, 2016 19:04
-
-
Save sethschori/1203b13181e663f782fb3c879d0aeb4c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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')); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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