true 。否则,返回false 。 回文是一个单词或句子,其拼写方式与前后相同,忽略标点符号,大小写和间距。 注意 "racecar" , "RaceCar"和"race CAR"等等。我们还将传递带有特殊符号的字符串,例如"2A3*3a2" , "2A3 3a2"和"2_A3*3#A2" 。如果卡住,请记得使用Read-Search-Ask 。编写自己的代码。 palindrome("eye")应该返回一个布尔值。
testString: 'assert(typeof palindrome("eye") === "boolean", "palindrome("eye") should return a boolean.");'
- text: palindrome("eye")应该返回true。
testString: 'assert(palindrome("eye") === true, "palindrome("eye") should return true.");'
- text: palindrome("_eye")应该返回true。
testString: 'assert(palindrome("_eye") === true, "palindrome("_eye") should return true.");'
- text: palindrome("race car")应该返回true。
testString: 'assert(palindrome("race car") === true, "palindrome("race car") should return true.");'
- text: palindrome("not a palindrome")应该返回false。
testString: 'assert(palindrome("not a palindrome") === false, "palindrome("not a palindrome") should return false.");'
- text: 'palindrome("A man, a plan, a canal. Panama")应该回归真实。'
testString: 'assert(palindrome("A man, a plan, a canal. Panama") === true, "palindrome("A man, a plan, a canal. Panama") should return true.");'
- text: palindrome("never odd or even")应该返回true。
testString: 'assert(palindrome("never odd or even") === true, "palindrome("never odd or even") should return true.");'
- text: palindrome("nope")应该返回false。
testString: 'assert(palindrome("nope") === false, "palindrome("nope") should return false.");'
- text: palindrome("almostomla")应该返回false。
testString: 'assert(palindrome("almostomla") === false, "palindrome("almostomla") should return false.");'
- text: 'palindrome("My age is 0, 0 si ega ym.")应该返回true。'
testString: 'assert(palindrome("My age is 0, 0 si ega ym.") === true, "palindrome("My age is 0, 0 si ega ym.") should return true.");'
- text: palindrome("1 eye for of 1 eye.")应该返回假。
testString: 'assert(palindrome("1 eye for of 1 eye.") === false, "palindrome("1 eye for of 1 eye.") should return false.");'
- text: 'palindrome("0_0 (: /-\ :) 0-0")应该返回true。'
testString: 'assert(palindrome("0_0 (: /-\ :) 0-0") === true, "palindrome("0_0 (: /-\ :) 0-0") should return true.");'
- text: palindrome("five|\_/|four")应该返回false。
testString: 'assert(palindrome("five|\_/|four") === false, "palindrome("five|\_/|four") should return false.");'
```