Hola, soy nuevo en la codificación y actualmente trabajo con var , cuando coloco el código siempre devuelve "undefine" . No puedo decir lo que estoy haciendo mal. ¿Alguien sabe? El código es el siguiente:
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; }Si desea que un método devuelva un valor, agregue la palabra clave de return en la última línea.
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; }