I am hoping that I can get some help with my learning and find out what it is about my function that is not working correctly:
function contains() {
var substr = 'bar';
var str = 'foobar';
if (str.indexOf(substr)) {
// Return true if substr is a substring of str
return true;
} else {
// and false if substr is not a substring of str
return false;
};
}
Thank you in advance for anyone who can help me get over this bump in learning.
Rob
return str.indexOf(substr) > -1;.