how to reverse a interger in javascfri[t code example
Example 1: reverse int js
function reverseInt(n) {
let reversed = n.toString().split("").reverse().join("");
//from string to integer
reversed = parseInt(reversed);
if (n < 0) {
return reversed * -1;
}
return reversed;
}
Example 2: reverse int js
function reverseInt(n) {
const reversed = n.toString().split("").reverse().join("");
return parseInt(reversed) * Math.sign(n);
}