const readline = require("readline");
rl.question("What is your name? ", function (answer) {
console.log(`Oh, so your name is ${answer}`);
});
const readline = require("readline");
const ac = new AbortController();
const signal = ac.signal;
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
});
rl.question("What is your name? ", { signal }, (answer) => {
console.log(`Oh, so your name is ${answer}`);
console.log("Closing the console");
process.exit();
});
signal.addEventListener(
"abort",
() => {
console.log("The name question timed out!");
},
{ once: true }
);
setTimeout(() => {
ac.abort();
process.exit();
}, 10000); // 10 seconds
there's not input console you can get the value from input in html
ex:
<input type="text" id="inp">
<button onclick="show()"></button>
//javascript
var text = document.getElementById("inp")
function show(){
alert(text.value)
}