Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript JavaScript and the DOM (Retiring) Responding to User Interaction Functions as Parameters

Gremyko Coleman
Gremyko Coleman
8,876 Points

How would you do this same example of passing a function into another function using arrow functions instead?

I don't get it, Guil was using arrow functions earlier in this track, but for this example he uses the old style of declaring function, so, its confusing me. I don't know how to use this same example in the video using arrow functions instead.

function say(something){
    console.log(something);
}

function exec(func, arg){
    func(arg);
}

exec(say, "hi, there");
Julian French
Julian French
3,257 Points

Hey, would you mind pasting in the example code here? Thanks!

Frank Rose
Frank Rose
25,162 Points

Let me know if this helps

const say  = something => {
    console.log(something);
}

const exec = (func, arg) => {
    func(arg);
}

exec(say, "hi, there");

1 Answer

Hello, there.

I know this is a old question, buy maybe you can still use this answer, or other students in the Community.

const exec = (func, arg) => func(arg); exec(something => console.log(something), 'Hi there')

That would work