Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Reverse a number in JavaScript

let rev = 0;
let num = 123456;
let lastDigit;

while(num != 0){
	lastDigit = num % 10;
  rev = rev * 10 + lastDigit;
  num = Math.floor(num/10);
}

console.log("Reverse number : "+rev);
Source by www.codevscolor.com #
 
PREVIOUS NEXT
Tagged: #Reverse #number #JavaScript
ADD COMMENT
Topic
Name
4+6 =