+ 2

Please find the mistake of the wed program

https://code.sololearn.com/Wy5YGgMV0lby/?ref=app

14th Feb 2023, 4:31 AM
Abhinav.S
Abhinav.S - avatar
2 Antworten
+ 3
Your rev variable is not initialized so it takes undefind value so rev*10 is NaN. Assign to default value first rev=0; In js division is float division operator So 12/10=>1.2 , not 1 so apply Math.floor(12/10) method. For negetive values use Math.truncate(). No need to apply Number() for all operations. Just apply for input. For just single comparision, better to use if-else over switch.
14th Feb 2023, 2:42 PM
Jayakrishna 🇮🇳
0
Use parseInt() instead of Number() inside while loop.
14th Feb 2023, 5:57 AM
Rupan Samanta
Rupan Samanta - avatar