写一个方法,让"1234"变成回文数字“1234321”,就是顺着读和倒着读都是一样的;注:不让用reverse()方法;
function palindrome(str){
var arr = str.split("");
var arr1 = [];
for (var i = arr.length - 1; i >= 0; i--) {
arr1.push(arr[i]); } var arr2=arr.concat(arr1); var index=arr2.length/2; arr2.splice(index,1); return arr2.join("");
}
console.log(palindrome("1234"));