Day 34: Reverse Number of Number of 100DaysCodingChallenge
Hello all,
I have started the 100 days of coding challenge to improve my programming skills..
Today is the Day34 of 100DaysCodingChallenge for
Reverse Number of input Numbers taken by the user.
Code :
let n = prompt("Enter a Number : "); let n1 = n; let rev = 0, rem; while (n > 0) { //console.log(n % 10); //console.log(rev * 10); //console.log(rev * 10 + rem); //console.log(n /= 10); rem = n % 10; rev = rev * 10 + n % 10; n = Math.floor(n/10); } console.log("The Reverse Number of", n1, "is :", rev);
Output :
Happy Coding:)
Thank you...
Comments
Post a Comment