Find the Index of the First Occurrence in a String
- javascript
- strings
Problem URL:Find the Index of the First Occurrence in a String
My Solution:
/**
* @param {string} haystack
* @param {string} needle
* @return {number}
*/
var strStr = function(haystack, needle) {
if (needle.length === 0) {
return 0;
}
return haystack.indexOf(needle);
};
Let's Connect
Twitter •GitHub •LinkedIn