PROBLEM 30
Easy

Reverse a Three-Digit Number

Programming Basics · JavaScript

</>
STATUS Not solved

TASK

Problem

#30

Given a positive three-digit integer, print its digits reversed as a number.

EXAMPLE

Example

Input
307
Output
703

LIMITS

Constraints

100 ≤ n ≤ 999
📖
LEARN Theory for this problem
+

### Reverse a Three-Digit Number

Integer division separates higher decimal/time units, while `%` returns the remainder. These two operations let a program isolate digits or split a total number of seconds/minutes into components.

💡
NEED HELP? Hints
+

['Decide which part comes from division and which part comes from the remainder.', 'Separate input parsing, result computation, and output into distinct steps so errors are easier to spot.']

ANSWER Solution
+
const fs = require('fs');

const text = fs.readFileSync(0, 'utf8').trim();
const reversed = Number([...text].reverse().join(''));

console.log(reversed);