Posted on 2005-03-14
I am having problems with the following function. The function is supposed to take a sting of 'Ab' and return it back as 'aB' Instead this function for some reason is returning the string as 'aBb' I know that it is returning part of the original string but I have had no luck whats so ever in fixing this. Can aonyone help me spot the error. the code is as follows:
* Function returns true if its single-character string
* argument is a lowercase alphabetic character.
* Required for implementation of reverseCase.
return (aCharacter >= 'a') && (aCharacter <= 'z')
* Function returns
* a new string which has the same
* characters as aString except that all
* lowercase characters are replaced by
* their uppercase equivalents, and all
* uppercase characters are replaced by
* their lowercase equivalents.
var newString; //the string to be returned
newString = ''; //initialise the string to be returned
for (var index = 0; index < aString.length; index = index + 1)
newString = newString + aString.charAt(index).toUpperCase()
newString = newString + aString.charAt(index).toLowerCase()
Many Thansk to anyone who can help!!