+ 1
How to accept user input when working with JavaScript??
When I try to solve JavaScript solution in Sololearn I don't understand how to accept user input. So how can I get it?
12 Answers
+ 3
Amansisa Tadese
I have also struggled with this problem, so have 2 suggestions for you
When trying to resolve a challenge in Playground, I replace the input with a pre-written example for the code to test
var example = readline() // replace
var example = "test this instead"
If you wish, you could also play with this snippet written by Vasiliy
https://code.sololearn.com/cdCpP5P11Ykj/?ref=app
Abhay Could you elaborate further regarding prompt() as it did not work for me when I tested.
+ 3
Thanks Abhay and Rik Wittkopp I get some points:๐๐
+ 2
Abhay
I get confused by it also
Constantly ๐คฃ๐
+ 2
prompt('Your-Text-Here')
Is The Only Method to Receive input in Web JS...
+ 2
Sancho Godinho [DM Free] thank you
+ 1
prompt() .
You can use input element as well.
+ 1
Abhay
I thought they were the same because I have only ever completed Javascript, yet am getting invites to assist with node js.
+ 1
Rik Wittkopp op is asking about input in javascript but now i re read the question , it seems like they are talking about node js !
+ 1
Amansisa Tadese
Welcome ๐.
Also, Are You Amansisa Tandese Gudina?
+ 1
Sancho Godinho [DM Free] Yes. I left that account since I lost my email...
0
function main() {
let name = readLine();
userName(name);
}
function userName(name){
//complete the function
//use backtick (` `) for template literal
let msg = `Welcome, ${name}!`;
console.log(msg);
}
- 1
Rik Wittkopp node js or javascript ?