JavaScript function syntax error confusion

Viewed 48

I don't know whats wrong with this code

  var createWorker = function(){
  var task1 = function(){
     console.log("this is job1");
  };
  var task2 = function(){
     console.log("this is job2");
  };

   return
   {
      job1: task1,
      job2: task2
   };
};
var worker = createWorker();
worker.job1();
worker.job2();

This gives the syntax error but I think the syntax is right. Can anyone help? Thank you.

1 Answers
Related