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 trialGremyko Coleman
9,756 PointsHow 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");
abcdefte
25,162 PointsLet me know if this helps
const say = something => {
console.log(something);
}
const exec = (func, arg) => {
func(arg);
}
exec(say, "hi, there");
1 Answer
DANIEL CALDERON V
8,407 PointsHello, 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
Julian French
3,257 PointsJulian French
3,257 PointsHey, would you mind pasting in the example code here? Thanks!