Here is the challenge I need help with:
Create a variable called
myFriendusing one of the variable declarations described above (var,let, orconst). Set the variable you created to contain your friend's name. Inside the greetings function, return the string: "Greetings [your-friend's-name].
New to this, but I can't seem to find out where the error is. Probably easy for you guys but, I'll get there.enter image description here
var myFriend = "Sara"
function greetings() {
let greetings = "greetings, " + myFriend
}
console.log('results: ,'+greetings());
greetingswhy do you expect that it should be anything else thanundefined.return greetingsin your function and use+to concenate a string with that return from your fucntion in console log.Unable to access variable within a functionis not really the correct title? AccessingmyFriendin the function works perfectly well there.