PROBLEM 29
Easy

Reverse a Two-Digit Number

Programming Basics · JavaScript

</>
STATUS Not solved

TASK

Problem

#29

Given a positive two-digit integer, swap its digits and print the resulting number.

EXAMPLE

Example

Input
42
Output
24

LIMITS

Constraints

10 ≤ n ≤ 99
📖
LEARN Theory for this problem
+

### Reverse a Two-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.', 'Before printing, output only the computed result and do not add explanatory text that is absent from the required format.']

ANSWER Solution
+
const fs = require('fs');
const input = fs.readFileSync(0, 'utf8').trimEnd();
let n = Number(input);
let a = Math.floor((n) / (10));
let b = (((n) % (10)) + (10)) % (10);
console.log(((b) * (10)) + a);