How do I allow any name to be used?

Very newb here so please forgive the incoming very dumb question, I keep scrolling through the material and can’t find the appropriate lesson (although I’m sure it’s probably somewhere obvious) I’m not sure if I’m wording this correctly…

I want to know how to allow any name to be used and not stuck with only one name and when you type in a different name it just comes back as undefined.

So far I only have:

let name = ("");

`${name}`

I know it’s either all wrong or I’m missing parts but I can’t figure it out.

You can initialize a variable without a value then define a value later,

let name;

name = 'whatever';

Is this what you are asking about?

if what you are saying is that if you a define variable “name” and give it a value and later want to change that value then all you have to do is when you are typing the variable start with “let” then you can modify it as many number of times you want but don’t name it starting with “const” as if you name it with “const” you can’t change it later on.

let name = "Jackie" name = "Vincent" console.log(name)

I put it in as you did and I still got back an undefined…I’m wanting it to be for a getReply scenario:

const getReply = (userInput) => {
if (level === 0) {
level = 1;
if (userInput === name) {
return “Nice to meet you, name. How are you today?”;
}
}

How do I allow anyone’s name to be used and it accepted in the return message?

I’m wanting it to be for a getReply scenario:

const getReply = (userInput) => {
if (level === 0) {
level = 1;
if (userInput === name) {
return “Nice to meet you, name. How are you today?”;
}
}

How do I allow anyone’s name to be used and it accepted in the return message?

As your function is currently written, getReply accepts userInput as an argument.
It then checks against a couple of global? variables in a a nested if statement.

First level is checked and level is equal to zero, the function then checks is userInput is equal to name. If both conditions evaluate to true then the function will return Nice to meet you, name. How are you today?.

If either of the conditions evaluate to false, nothing is returned and you will receive undefined.

In order to use the name variable in your returned string, you’ll need to wrap the string in backticks and use string interpolation like so:

return  `Nice to meet you, ${name}. How are you today?`;
// Global Variables let level = 0; let name = 'Joe'; // getReply function const getReply = (userInput) => { if (level === 0) { level = 1; if (userInput === name) { return `Nice to meet you ${name}. How are you today?`; } } }; // returns Nice to meet you Joe. How are you today? console.log(getReply('Joe')); // returns undefined console.log(getReply('Mike'));