README fixes.

This commit is contained in:
Oleksii Trekhleb
2022-01-22 10:50:33 +01:00
parent 80d2f508d3
commit 7d13e6863a
3 changed files with 5 additions and 2 deletions

View File

@ -43,7 +43,7 @@ export default function knuthMorrisPratt(text, word) {
if (text[textIndex] === word[wordIndex]) {
// We've found a match.
if (wordIndex === word.length - 1) {
return textIndex - word.length + 1;
return (textIndex - word.length) + 1;
}
wordIndex += 1;
textIndex += 1;