function palindrome(str) {
// Good luck!
str = str.toLowerCase();
str = str.match(/[a-z,0-9]/g);
var str1 = str;
str.reverse();
return str + " vs " + str1;
}
palindrome("1 eye for of 1 eye.")为啥str和str1 都会翻转,变成一样的?
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
str = str.match(/[a-z,0-9]/g); 这句的时候str已经不再是String 而是Array了