-4

EDIT >> readline is not working, getting this message in the terminal "ReferenceError: readline is not defined"

Javascript noob here

I'm writing a program where I am trying to get an int from the user. I know how to do this usually within a HTML document however nothing is working within the .js file which I am running in the terminal of my linux machine.

for instance I want to say

console.log("enter your number");
//code that collects the int named var yourint
console.log ("your number was " + yourint);

It's really battering my brain, because I know I'm just drawing a blank and the solution is obvious.

Patrick Evans
  • 41,991
  • 6
  • 74
  • 87
Bartholomew
  • 9
  • 1
  • 1
  • 5

1 Answers1

0

console.log is outputs a message to a web console not a shell

https://developer.mozilla.org/en-US/docs/Web/API/Console/log

if you are using js24 in linux it will throw an error like

typein:1:0 ReferenceError: console is not defined

you might want to use print

example

var input=readline('enter your number');
print('your number was '+input)
repzero
  • 8,254
  • 2
  • 18
  • 40