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 Gulp Basics Welcome to Gulp.js Create your first gulp task

Ricard Taujenis
Ricard Taujenis
4,383 Points

In the 'goodbye' task, create an anonymous callback function as the second parameter. In the body of the function, log t

Not sure how to implement the callback function

gulpfile.js
var gulp = require('gulp')
gulp.task('goodbye') ; 
consle.log("goodbye!")

2 Answers

Nicholas Grenwalt
Nicholas Grenwalt
46,626 Points

The console.log method has to be inside an anonymous function. To do that you pass in the anonymous function as the second argument (i.e. 'function() {}' ) and between its brackets is where the console.log will go to be ran when gulp is triggered. Provided a code snippet to clarify. Keep up the coding.

var gulp = require('gulp');

gulp.task('goodbye', function(){
  console.log("goodbye!");
});
Ricard Taujenis
Ricard Taujenis
4,383 Points

thx a lot so basically function() inner brackets have to stay intact so the gulp would run otherwise there will be a syntacs error?

Hi Richard,

A callback function is basically just an anonymous function you define as an argument. So what you're looking for here is:

var gulp = require('gulp');

gulp.task('goodbye', function() {
  console.log("goodbye!");
});

The ...function()... etc is the callback function, which is being passed as a parameter on gulp.task.

Hope that helps!