Having some trouble with my code..
function compare(string,pattern){
var patternUpper = pattern.toUpperCase(); // Convert pattern to uppercase
var stringUpper = string.toUpperCase(); // Convert string to uppercase
for(var i=0;i<stringUpper.length-1;i++){
if(stringUpper.indexOf(patternUpper.charAt(i))<0)
return false;
}
return true;
}
I'm puzzled by the "pattern is undefined" error message in Firefox debugger, even though it's clearly defined in the function. Any ideas why?
Any assistance would be greatly appreciated.
- Liam
UPDATE: The debugger is also reporting "string is undefined" when I comment out the second line of that snippet.
The call to compare2 is made here:
alert(compare("thisisatest","ahtsit"));
The result seems correct, but I believe this issue could be causing problems elsewhere in my program.