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 trialUmar Ali
7,202 PointsChallenge Task 1 of 1 Convert the greet function declaration to an arrow function.
const greet = (val) => {
return `Hi, ${val}!`;
}
greet('cool coders');
Tom Nguyen
33,500 PointsThis is the solution. works for me.
lance rangel
2,016 PointsThe issue is due to the semicolon after the return statement. It should go at the end of the functions closing bracket as such:
const greet = (val) => {
return `Hi, ${val}!`
};
greet('cool coders');
A couple of other ways to do this in one line would be:
const greet = val => `Hi, ${val}!`;
//or
const greet = (val = 'cool coders') => `Hi, ${val}!`;
I hope this helps!
Steven Parker
231,248 PointsActually, it's correct (and "best practice") to put a semicolon after the assignment and after the return statement.
But they are both optional, neither one is necessary for the code to function correctly.
6 Answers
ryantalbot2
12,537 Pointsconst greet = (val) => {
return `Hi, ${val}!`;
}
greet('cool coders');
Steven Parker
231,248 PointsAre you suggesting something to change? I can't see any difference from the original code here.
Steven Parker
231,248 PointsWhat kind of error do you get? This looks OK, and when I paste it directly into the challenge, it passes!
You might try restarting your browser.
Lateefah Camacho
3,067 Pointsconst greet =(val) => {
greet('cool coders');
return Hi, ${val}!
;
};
copy and paste reformatted post.
Christopher Kehl
18,180 PointsThat was very odd. It doesn't work in a browser but if you paste the code above into the challenge it passes.
FRANKIE Ochoa
2,759 Pointscan someone please help me I'm so lost i hate JavaScript :(
ayawovi Badohoun
10,334 Pointsconst greet = (val) => {
return Hi, ${val}!
;
}
greet('cool coders'); this works
Umar Ali
7,202 PointsUmar Ali
7,202 PointsAnswer is in the code.