Last active
October 28, 2016 16:59
-
-
Save pietro909/987d2015dbce8c89d259e2b72fa17c2a to your computer and use it in GitHub Desktop.
A runtime error in Javascript
This file contains 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 = s.indexOf(c); | |
return index > -1; | |
} | |
console.log(contains("hi", "there")); // false | |
console.log(contains("hi", "hi, all")); // true | |
console.log(contains("hi", 1)); // TypeError: s.indexOf is not a function | |
console.log(contains("hi", null)); // TypeError: Cannot read property 'indexOf' of null |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment