take console input in js code example
Example 1: javascript console input
//SpiderMonkey
var input = readline();
//Vanilla javascript
var input = prompt("Enter input:");
Example 2: get console javascript
//What you can do is hook the console.log function so that you store when it logs :
console.stdlog = console.log.bind(console);
console.logs = [];
console.log = function(){
console.logs.push(Array.from(arguments));
console.stdlog.apply(console, arguments);
}