- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Reverse numbers in function without using reverse() method in JavaScript
We are required to write a JavaScript function that takes in a number and returns its reversed number with converting it to an array or string.
Let's write the code for this function −
Example
const num = 234567; const reverseNumber = (num, res = 0) => { if(num){ return reverseNumber(Math.floor(num / 10), (res*10)+(num % 10)); }; return res; }; console.log(reverseNumber(num)); console.log(reverseNumber(53536)); console.log(reverseNumber(76576));
Output
The output in the console will be −
765432 63535 67567
- Related Articles
- Write program to reverse a String without using reverse() method in Java?
- String reverse vs reverse! function in Ruby
- Reverse digits of an integer in JavaScript without using array or string methods
- Function to reverse a string JavaScript
- Write a C program to Reverse a string without using a library function
- Array reverse() in JavaScript
- Python Program to Reverse a String without using Recursion
- List reverse function in C++ STL
- Reverse and Add Function in Java
- Reverse a number in JavaScript
- JavaScript Array reverse()
- Returning reverse array of integers using JavaScript
- C# Linq Reverse Method
- Array reverse() vs reverse! in Ruby
- Reverse alphabetically sorted strings in JavaScript

Advertisements