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 trialNas Jones
7,849 PointsChallenge task help
I don't understand what's wrong what should i do to fix this?
greet('cool coders');
const greet = (val) => {
return `Hi, ${val}!`;
}
2 Answers
Cameron Childres
11,820 PointsHi Haki,
Your arrow function is looking good. Note that you call the function, and then you define it. Pay attention to the hint on this challenge:
HINT: Arrow functions are not hoisted – or lifted – to the top of their scope. Calling an arrow function before it's defined produces an error
John D
7,237 PointsYou've already defined the function, the only difference is that you are using an arrow function which means that it must be defined before calling it:
you called
greet('cool coders');
before your arrow function. Try switching them around! It should work.
Nas Jones
7,849 PointsThanks for the help!
Nas Jones
7,849 PointsNas Jones
7,849 PointsThank you but i still don't understand how would i define it, I just started doing this not too long ago so i'm not that good at it. How would i define the function when i call it?
Cameron Childres
11,820 PointsCameron Childres
11,820 PointsThis is where you've called the function:
greet('cool coders');
This is where you've defined it:
They're simply out of order. Move your call to the bottom, below the definition.
Nas Jones
7,849 PointsNas Jones
7,849 PointsI got it now thank you for the help!