reverse number javascript
snippet in javascript

reverse number javascript

user1872

// Function to reverse Number
function reverseNum(n) {
  let r = n.toString().split('').reverse().join('');
  return Math.sign(n) * parseInt(r);
}

// Call
reverseNum(-267);
reverseNum(31522);

// Outputs
-762
22513

how to flip a Number in javascript

user4433

function reverse_a_number(n)
{
	n = n + "";
	return n.split("").reverse().join("");
}
console.log(reverse_a_number(32243));