Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

242
Views
Why am I getting ':' expected"? I'm trying to define a few functions to run some unit tests on for a benchmark

I'm trying to get these functions defined to run some synchronous and asynchronous test cases on them with Mocha and Chai in JS, what am I doing wrong? Why is my editor marking certain lines?enter image description here

module.exports = {

    function myFunctiona ()  {
      
    }
        
    
    
    function myFunctionb ()  {
        for (let i = 0; i < 10000; i++) {
          new Date();
        }
      }
    
    function myFunctionc(done)  {
        setTimeout(done, 0);
      }
      
    function myFunctiond (done) {
        setTimeout(done, Math.round(Math.random() * 10));
      }
    
    }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

This is a syntax error because you're defining an object with properties, but you don't have property keys. See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Missing_colon_after_property_id for more information.

Typically, you'd define an object like the following (note the commas after each property too):

var object = {
    property1: 'thing',
    property2: function() {
        return 'thing2';
    }
}

so to change your functions to properties, set the property key as the function name, and then assign a function to it like:

module.exports = {

    myFunctiona: function ()  {
        //nothing
    },

    myFunctionb: function ()  {
        for (let i = 0; i < 10000; i++) {
            new Date();
        }
    },

    myFunctionc: function (done)  {
        setTimeout(done, 0);
    },

    myFunctiond: function (done) {
        setTimeout(done, Math.round(Math.random() * 10));
    }

};
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!