Answers for "reverse number 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

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;
}
Posted by: Guest on June-19-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
0

reverse int js

function reverseInt(n) {
  const reversed = n.toString().split("").reverse().join(""); 

  return parseInt(reversed) * Math.sign(n);
}
Posted by: Guest on July-28-2020
0

js reverse number

const reversedNum = num => parseFloat(num.toString().split('').reverse().join('')) * Math.sign(num)
Posted by: Guest on August-06-2020
0

reverse number javascript

var r,rev=0,n;
n = parseInt(prompt("enter a number:"));
for(;n != 0; n = parseInt(n / 10))
{
    r = n % 10;
    rev = rev * 10 + r;
}
document.write("reverse of number is:"+rev);
Posted by: coder on September-07-2022

Code answers related to "Javascript"

Browse Popular Code Answers by Language