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

174
Views
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 answers
Answer question

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 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!