Last active
October 28, 2016 08:33
-
-
Save pietro909/587ff2336a92eb5357d0fd002349eaec to your computer and use it in GitHub Desktop.
Example of how to handle unknown input
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
function contains(c, s) { | |
var index = typeof s === 'string' ? s.indexOf(c) : -1; | |
return index > -1; | |
} | |
console.log(contains("hi", "there")); // false | |
console.log(contains("hi", "hi, all")); // true | |
console.log(contains("hi", 1)); // false | |
console.log(contains("hi", null)); // false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment