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 Create an Arrow Function

JavaScript Functions JavaScript Task 1 of 1

I thought that this would work but it didn't. Though I needed parenthesis for the return, but it still didn't work. Why?

script.js
const greet = val => return(`Hi, ${val}!`);

greet('cool coders');

1 Answer

Simon Coates
Simon Coates
8,177 Points

I haven't done javascript syntax in ages, but I'd only use the return statement with {}. So the following seems to work:

const greet = val => `Hi, ${val}!`;

greet('cool coders');
// ouputs "Hi, cool coders!"
const greetx = val => { return `Hi, ${val}!`; };

greetx('cool coders');
//outputs: "Hi, cool coders!"