Answers for "how to flip a Number in javascript"

5

reverse number javascript

// 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
Posted by: Guest on March-12-2020
1

how to flip a Number in javascript

function reverse_a_number(n)
{
	n = n + "";
	return n.split("").reverse().join("");
}
console.log(reverse_a_number(32243));
Posted by: Guest on March-23-2020

Code answers related to "how to flip a Number in javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language