1// Function to reverse Number
2function reverseNum(n) {
3 let r = n.toString().split('').reverse().join('');
4 return Math.sign(n) * parseInt(r);
5}
6
7// Call
8reverseNum(-267);
9reverseNum(31522);
10
11// Outputs
12-762
1322513
1function reverseInt(n) {
2 let reversed = n.toString().split("").reverse().join("");
3 //from string to integer
4 reversed = parseInt(reversed);
5
6 if (n < 0) {
7 return reversed * -1;
8 }
9
10 return reversed;
11}
1function reverse_a_number(n)
2{
3 n = n + "";
4 return n.split("").reverse().join("");
5}
6console.log(reverse_a_number(32243));
7
1function reverseInt(n) {
2 const reversed = n.toString().split("").reverse().join("");
3
4 return parseInt(reversed) * Math.sign(n);
5}
1const reversedNum = num => parseFloat(num.toString().split('').reverse().join('')) * Math.sign(num)