x=123 let str = x.toString(); console.log(str) let newStr =[]; for(let i = 0;i<=str.length-1;i++){ newStr[i] = str[str.length-1-i] } let str2 = newStr.join('') console.log(str2) let str3 = parseInt(str2) console.log(str3)