Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript Introducing ES2015 The Cooler Parts of ES2015 Default Parameters

Vladimir Plokhotniuk
Vladimir Plokhotniuk
5,464 Points

Introducing ES2015, dont working the same code

hi, i copied the code in WebStorm, but in console.log i have this " Good undefined, undefined! " Then i cannot working from this beginning step ( What is wrong?

function greet(name, timeOfDay) { console.log(Good ${timeOfDay}, ${name}!); } greet()

4 Answers

Hannah De Los Reyes
Hannah De Los Reyes
18,289 Points

You are missing the back-ticks around Good ${timeOfDay}, ${name}!

Also, like others have said, you need to pass in arguments when you call the function.

Steven Parker
Steven Parker
229,785 Points

The back-ticks were used in the question, but were not shown because the code is not formatted. Use the instructions for code formatting in the Markdown Cheatsheet pop-up below the "Add an Answer" area. :arrow_heading_down:   Or watch this video on code formatting.

Steven Parker
Steven Parker
229,785 Points

The "greet" function shown here is designed to take two arguments, and include them in the display.

But when you call it without arguments ("greet()"), the system displays "undefined" in the places that the values would be shown.

So when you call it, pass it some arguments to use. For example:

greet("Vladimir", "morning");
Fradely Dilone
Fradely Dilone
24,037 Points

All the workspaces starting AJAX by Js full-stack course have errors

function greet(name, timeOfDay) {
 console.log(`Good ${timeOfDay}, ${name}!`); 
} 

//You need to pass the parameters to the function, like this:
greet("Paco","15:00");
Vladimir Plokhotniuk
Vladimir Plokhotniuk
5,464 Points

Thanks to everyone. I entered another character, like " ' " instead of " ` ". I did not know that they affect the function differently.

Steven Parker
Steven Parker
229,785 Points

I could tell that you had used backticks correctly by the way the font changed. To have code appear correctly, see the instructions I mentioned in my previous comment.