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

Susanna Clough
seal-mask
.a{fill-rule:evenodd;}techdegree
Susanna Clough
Full Stack JavaScript Techdegree Student 1,678 Points

It looks correct to me! Please help!

The message "make sure to pass 'greet' a string" keeps coming up. My code looks identical to the hints and to my notes.

script.js
const greet = ('cool coders') => {

};

function greet(val) {
  return `Hi, ${val}!`;
}

3 Answers

Hey Susanna Clough,

The code you have written is incorrect because you are trying to convert a call greet('cool coders') into arrow function.

Try the following code:

Here, I have converted function declaration into arrow function and then called by its name.

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

greet('cool coders');

Hope this helps!!

Why is the function call at the bottom of the file? :)

I recommend clicking the restart button and trying again. In this challenge, you should be converting the function declaration into an arrow function. You converted the function call into one instead.

Let me know if this helps!

Arrow function are not hoisted like function declaration therefore it needs to be called after it's been defined.