2
function palindrome(str) { // "Hello there"
str.toLowerCase(); // "hello there"
str = str.replace(/\s/g, ""); // "hellothere"
var a = str;
a.split("").reverse().join(""); // a = "erehtolleh"
return (str === a); // "hellothere" === "erehtolleh"
}
alert(palindrome("123432"));
123432
을 통과하지만, 사실 값을 반환합니다. 내 palindrome 기능에 문제가있는 사람은 누구입니까? 누군가 내 논리를 점검 할 수 있다면 정말 고맙겠습니다. 당신이 변수에 반전 된 문자열을 할당해야 또는 비교 않도록
왜이 변질 "말라얄람어은"? 'palindrome' 함수를 호출하는 것을 의미합니까? –
오 예, 기능을 호출하는 것을 잊었습니다; 0) –