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

184
Visualizações
Following code input comes out undefined error

Hi I'm new to coding and currently working with var, when I put the code always returns "undefine" I can't tell what I'm doing wrong does anyone knows? The code is as follows:

function greetings() 
{
  var myFriend = "Jeff"; 
  var greetings = "Welcome back, " + myFriend + "!" 
}

// leave this line unchanged to console log the results
console.log('results: ', greetings());

// don't change this line
if (typeof module !== 'undefined')
{ 
  module.exports = greetings;
}

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

If you want a method to return a value, add the return keyword on the last line.

function greetings() {
  var myFriend = "Jeff";
  var greetings = "Welcome back, " + myFriend + "!" 
  
  /* You should add the following line. */
  return greetings;
}

console.log('results: ', greetings());

// Don't change this line
if (typeof module !== 'undefined') {
  module.exports = greetings;
}

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