0

This is a code to find the reverse of a number. I understand the logic but I don't understand why it is so Someone pls explain.

Reverse of a Number - JavaScript https://code.sololearn.com/W9mrLFq098tk/?ref=app

16th Sep 2020, 7:57 PM
Logos
Logos - avatar
5 Réponses
+ 1
What's your question? For code advertising use your personal feed post..
16th Sep 2020, 8:02 PM
Jayakrishna 🇮🇳
+ 1
Edewor Righteous For example input is 1234 Then by code first iteration no=1234; while(no>0) { a=no%10; //now a =1234%10=4. no=parseInt(no/10); //no=no/10=>1234/10=123 temp=temp*10+a; //here temp=0*10 + a = 4 } In next iteration no =123. And a = no%10=123%10=3 no=123/10=12 temp = temp*10 + a= > 4*10 + 3= 43 In next iteartion a=12%10=2 no=12/10=1 Temp=43*10+2=432 In next iteration : a =1%10=1 no=1/10=0 Temp = 432*10 + 1=4321 no>0 while condition is false now so loop stops here.. It alert(temp) =4321. Hope it clears..
16th Sep 2020, 8:53 PM
Jayakrishna 🇮🇳
+ 1
Yes I understand now. Thank you Jayakrishna🇮🇳
16th Sep 2020, 9:45 PM
Logos
Logos - avatar
0
No I'm not advertising. I don't understand the logic used in this code. I need some explanation. I'll repost. Please take a look at it again.
16th Sep 2020, 8:08 PM
Logos
Logos - avatar
0
You're welcome..
17th Sep 2020, 10:43 AM
Jayakrishna 🇮🇳