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

Where does "greeting" come from?

Also, why is that is written like: greeting => console.log()

and not
var greeting = () => console.log()

1 Answer

Not sure what you're meaning exactly. Is this a question from a course or challenge or something? The Arrow Function shorthand syntax:

greeting => console.log();

...allows you to declare a function that takes a single parameter (greeting) and returns a single expression (console.log()). I'm not really sure what use there is, since you're not logging anything to the console. I could see this as being more useful:

var saySomething = greeting => console.log(greeting);
saySomething('hello');
// logs 'hello' to console