Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

236
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda