Hello
Sure! Here's a simple JavaScript code that prompts the user to enter their name and then displays a welcome message:
javascript1// Prompt the user to enter their name 2var name = prompt("Please enter your name:"); 3 4// Display a welcome message 5console.log("Welcome, " + name + "!");
In this code, the prompt()
function is used to display a dialog box that asks the user to enter their name. The entered name is then stored in a variable called name
.
The console.log()
function is used to display a welcome message in the browser's console, which includes the entered name.