简体   繁体   中英

Console input, output in JavaScript

I am using WebStorm IDE 30 days trial version. While taking input in console I use readline().split(" ") method and print() method to write output but it's not working.

The following error is given:

Code:

var inp = readline().split(' ');
print(inp);

Error:

(function (exports, require, module, __filename, __dirname) { var inp = readline();
                                                                    ^

ReferenceError: readline is not defined
at Object.<anonymous> (D:\Work\J\JS.js:1:73)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.runMain (module.js:604:10)
at run (bootstrap_node.js:389:7)
at startup (bootstrap_node.js:149:9)
at bootstrap_node.js:504:3

Please see the example below. Say you want to create a JavaScript function that adds two numbers and prints out the output to the console in Webstorm.

function add(a,b){
return a+b;}

Console.log(add(5,6));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM