Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

234
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda