Created
May 3, 2025 10:40
-
-
Save Zodik09/3c6d76f5c14226ed745b70bdad4baac1 to your computer and use it in GitHub Desktop.
18. Reverse Without String Methods - Ask the user for a number and reverse it without using .split(), .reverse(), or join().
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// First run: npm i prompt-sync (in the terminal). | |
const prompt = require('prompt-sync')(); | |
const num = Number(prompt("Enter a number: ")); | |
strNum = num.toString(); | |
let result = ""; | |
for (let i = strNum.length - 1; i >= 0; i--) { | |
result += strNum[i]; | |
} | |
console.log(result); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment