Intro to JavaScript functions

I am confused as to why my output keeps sending back undefined when the variables are defined. How do I fix this issue?

you are calling your function makeShoppingList inside a console.log(). And because your function doesn’t have a return statement, your console.log() has nothing to log.

Try calling the function alone:
makeShoppingList('bread','milk','eggs');

The main takeaway here is that functions are called using their names, and do not need to be inside a console.log().

1 Like

The bottom line here is that if the function is doing the logging, then don’t log the call expression.

1 Like