0

How is this still wrong?

I don't understand what this bug is Getting user input Example Welcome, tom! let name = readLine(); console.log("Welcome," + name + "!");

23rd Aug 2023, 3:42 AM
Novan Rizky Setiawan
Novan Rizky Setiawan - avatar
7 Respostas
+ 6
Novan Rizky Setiawan The issue in your code is that the `readLine()`,this function is not valid JavaScript. The correct function to use for getting user input in JavaScript is `prompt()`. By using the `prompt()` function, a dialog box will appear where the user can input their name. See this modified version.. let name = prompt("Enter your name:"); console.log("Welcome, " + name + "!"); Note that.. Both `readline` and `prompt` are used to get user input in JavaScript, but they have different use cases. #`readline`: this module in Node.js that allows you to read input from the command line. It is commonly used for creating command-line interfaces or interactive command-line applications. #`prompt`this built-in function in web browsers that used to display a dialog box and get user input. It is commonly used for simple user interactions within a web page. Otherhand:- If you're having trouble in code, share your code and describe what error message you're receiving.
23rd Aug 2023, 4:31 AM
Darpan kesharwani🇮🇳[Inactive📚]
Darpan kesharwani🇮🇳[Inactive📚] - avatar
+ 2
Create a readline interface and use question method to prompt the user for input const rl = readline.createInterface({ input: process.stdin, output: process.stdout }); rl.question('Enter your name: ', function(name) { console.log("Welcome, " + name + "!"); rl.close(); }); If readline not defined import by const readline = require('readline'); Ensure that you're running the code in a terminal or command prompt, not within a code editor or an integrated development environment (IDE).
23rd Aug 2023, 4:16 AM
Raju Adhikary
Raju Adhikary - avatar
+ 1
But it doesn't work, it says there is a problem with the prompt, this is a stage in one of the javascript introductions in solo learn The title is string concatenation, I think I put the wrong code when I follow all the code the solution is the same What is a should i do? If the solution code is wrong
23rd Aug 2023, 5:55 AM
Novan Rizky Setiawan
Novan Rizky Setiawan - avatar
+ 1
Spaces are important in code coaches.
24th Aug 2023, 12:18 PM
Naveed
Naveed - avatar
0
Novan Rizky Setiawan , Could you kindly show your attempt here?
23rd Aug 2023, 8:23 AM
Dragon RB
Dragon RB - avatar
0
I made the same mistake the other day. You need to have a space after the comma in Welcome so the output will format correctly. Like this: console.log("Welcome, " + name + "!"); Hope this helps.
24th Aug 2023, 5:29 AM
Brenda Szuszczewicz
Brenda Szuszczewicz - avatar