我正在尝试测试密码。我需要对字符串进行一些测试。当我使用 toUpperCase() 测试我的特殊字符时,我发现它们的评估结果为真。我怀疑他们会评估为假。
我应该如何测试特殊字符?
// CREATE ARRAY OF CHARACTERS
CharacterArray = ["1","2","3","a","b","c","D","E","F","/","+",")"];
// TEST CHARACTERS
function testCharacters() {
// GET ARRAY LEN
var CharacterArrayLen = CharacterArray.length;
// LOOP THROUGH ARRAY
for (i = 0; i < CharacterArrayLen; i++) {
// PARSE SINGLE CHARACTER
var ThisChar = CharacterArray[i];
if (!isNaN(ThisChar)) {
alert(ThisChar + ' is numeric!');
} else {
if (ThisChar === ThisChar.toUpperCase()) {
alert(ThisChar + ' is upper case');
} else if (ThisChar === ThisChar.toLowerCase()) {
alert(ThisChar + " is lower case");
}
}
}
}
testCharacters();