if (str.indexOf(sub) == -1 ) return 0;
to the top and it works (when the index is -1 it means that the string is nowhere to be found)
dang it!