Check webpage code.
Wed Mar 15 2023 12:14:38 GMT+0000 (Coordinated Universal Time)
Saved by
@tygogakuvi
const name = prompt("What's your name?"); // ask for user's name
if (name) {
const greeting = `Hi ${name}! How can I assist you today?`;
console.log(greeting);
}
// Example function that uses the user's name in the response
function sayThanks() {
if (name) {
console.log(`Thank you, ${name}! I'm happy to help.`);
} else {
console.log("Thank you! I'm happy to help.");
}
}
This code prompts the user to enter their name using the prompt() method and stores the result
content_copyCOPY
https://chat.openai.com/chat
Comments