Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

nodejs ask for input

let userInput = ask("What is your name?")
//user types: Joe
console.log(userInput) // prints Joe

const prompt = require("prompt-sync")();  

function ask(message) {
  let input = prompt(message);
  return input;
}
Comment

Nodejs user input

// Importing the module
const readline = require("readline-sync");
  
// Enter the number
let a = Number(readline.question());
let number = [];
for (let i = 0; i < a; ++i) {
  number.push(Number(readline.question()));
}
console.log(number);
Comment

PREVIOUS NEXT
Code Example
Javascript :: node js list all installed modules 
Javascript :: regex email js 
Javascript :: is email js 
Javascript :: clear ctx canvas with javascript 
Javascript :: javascript get all array elements except last 
Javascript :: disable click event jquery 
Javascript :: console.log object object 
Javascript :: how to remove underline from material ui select 
Javascript :: javascript how to get a random element from an array 
Javascript :: js method string remove extra spaces 
Javascript :: javascript var dump 
Javascript :: for of get index 
Javascript :: kb to mb javascript 
Javascript :: show and hide div tag based on checkbox selection using jquery 
Javascript :: how to find parent table of tr in jquery 
Javascript :: javascript get body height 
Javascript :: RegExp validation for password explained 
Javascript :: get data in date filter sequelize 
Javascript :: how to set session storage in javascript 
Javascript :: clz32 
Javascript :: javascript innerhtml table 
Javascript :: NullInjectorError: R3InjectorError(DashboardModule)[DatabaseService - DatabaseService - HttpClient 
Javascript :: remove non prime numbers js 
Javascript :: remove css inline style javascript 
Javascript :: post antiforgerytoken jquery 
Javascript :: react get url querystring 
Javascript :: node js on ctrl c 
Javascript :: get index pixel of canvas 
Javascript :: javascript detect click outside element 
Javascript :: nodejs copy to clipboard 
ADD CONTENT
Topic
Content
Source link
Name
6+8 =