Skip to content

Instantly share code, notes, and snippets.

@Zodik09
Created May 3, 2025 10:40
Show Gist options
  • Save Zodik09/3c6d76f5c14226ed745b70bdad4baac1 to your computer and use it in GitHub Desktop.
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().
// 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