Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript JavaScript Functions Arrow Functions Concise Arrow Function Syntax

Arrow function example nets me a depreciated warning.

I was testing the various examples on this lesson, but when I submitted

const name = prompt(What's your name?); const greet = () => alert(Hello, ${name});

I found that while the prompt went off, the alert did not. I tested this in my playcode, and realized that the ${name} in the alert was listed as depreciated. Is there anything I can do, or is this something to do with my specific...is formatting the word to use?

2 Answers

Phil Wright
Phil Wright
3,654 Points

Hey Autumn

There is a bit of tidying up needed on your strings and string interpolation so you don't get any errors.

I've added an extra bit here too so that your greet variable (which has the arrow function assigned to it) gets invoked.

For visibility of what is being used where I’ve changed the variable name and the parameter for the arrow function.

So the first line assigns the prompted value to promptedName, then this variable is passed as an argument when greet is invoked and used to populate the template literal.

const promptedName = prompt("What's your name?"); 
const greet = (nameParameter) => alert(`Hello, ${nameParameter}`);

Perfection, that answers my question very nicely. Thank you!

const name = prompt(`What's your name?`); 
const greet = (nameParameter) => alert(`Hello, ${nameParameter}`);

There were a few things wrong with your code. I would recommend going over the videos again and following along. I went ahead and posted the answer for you so you can get an idea how to do it.