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;
}
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;
}