code lmao
This commit is contained in:
parent
a591aeb358
commit
16ce3441da
18
index.js
18
index.js
|
@ -0,0 +1,18 @@
|
|||
const readline = require('readline').createInterface({
|
||||
input: process.stdin,
|
||||
output: process.stdout
|
||||
})
|
||||
|
||||
readline.question(`Enter a number to convert: `, num => {
|
||||
num = parseInt(num)
|
||||
readline.question(`Enter a number new base: `, base => {
|
||||
base = parseInt(base)
|
||||
try {
|
||||
new_num = num.toString(base)
|
||||
console.log(`BASE 10:${num} ==> BASE ${base}: ${new_num}`);
|
||||
} catch (RangeError) {
|
||||
console.log(`Base is not in the range of 2 to 36.\nExiting...`);
|
||||
}
|
||||
readline.close()
|
||||
})
|
||||
})
|
Loading…
Reference in a new issue