In the for loop you should have isEqual = isEqual && string1[i] == string2[i];
Else it wouldn't matter, if the strings are of equal size and the last characters match, the strings are "equal" for this algorithm regardless of the rest of the characters