Can you help me with a JavaScript algorithm that can find a substring within a string?
subStringFinder('abbcdabbbbbck', 'ab')
This should return index 0.
Similarly,
subStringFinder('abbcdabbbbbck', 'bck')
should return index 10.
Would you be able to provide guidance on writing this code?
--UPDATE:
With the help of @Jonathan.Brink, I was able to write code that successfully achieved this:
function subStringFinder(str, subString) {
return str.indexOf(subString);
}
subStringFinder('abbcdabbbbbck', 'bck') // -> 10