Is there a function in jQuery or JavaScript that does the same as strstr()
in PHP?
I have an AJAX response that should be 1,2,3,12,13,23 or 123. I want
const isSame = function(indx, haystack, needle){
let j = 0;
for(let i=indx, len = indx + needle.length; i< len; i++) {
if (haystack[i] !== needle[j++]){
return false;
}
}
return true;
}
var strStr = function(haystack, needle) {
if (!needle) {
return 0;
}
for(let i=0; i
Base conditions:- when needle is empty string, it will return 0. If there is no match found it will return -1.