28. Implement strStr()
Implement strStr().
Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.
思路:采用js中的indexOf方法就可以了。
/** * @param {string} haystack * @param {string} needle * @return {number} */ var strStr = function(haystack, needle) { var number=haystack.indexOf(needle); return number; };