I'm a complete beginner. So, here on Stack Overflow I found this solution of "How to take multiple input using readline, but I can't find how to apply this the function. I put it in the main function and it takes input from me but it's not working. My output is showing NaN. Can anyone help me to fix this?
Here is my code
function simpleInterest (money, rate, time) {
simpleInterest=money*rate*time;
return simpleInterest;
}
let money;
let rate;
let time;
'use strict'
const readline = require('readline')
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
})
const question1 = () => {
return new Promise((resolve, reject) => {
rl.question('Total Money: ', (money) => {
resolve()
})
})
}
const question2 = () => {
return new Promise((resolve, reject) => {
rl.question('Interest Rate: ', (rate) => {
resolve()
})
})
}
const question3 = () => {
return new Promise((resolve, reject) => {
rl.question( 'How Many Years: ', (time) => {
resolve()
})
})
}
const main = async () => {
await question1()
await question2()
await question3()
//Here I'm calling the Function
let profit= simpleInterest(money, rate, time)
console.log("total", profit)
rl.close()
}
main()