function indexOf(strA, strB) {
var lenA = strA.length,
lenB = strB.length;
if (lenA < lenB) {
return -1;
} else if (lenA == lenB) {
return 0;
} else {
for (var j = 0; j < lenA; j++) {
if (strA.charAt(j) == strB[0] && strA.substr(j, lenB) == strB) {
return j;
}
}
return -1;
}
}
console.log(indexOf("hello", "el")); //1