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 JavaScript Basics (Retired) Creating Reusable Code with Functions Review: Getting Information from Functions

Yacine Freifer
Yacine Freifer
6,717 Points

Ok it says return but it is not outputting anywhere, no alert, console or document.write.

Regarding this question, the function is called but is nothing going to happen? Seeing as though the code is not being asked to be displayed in a console , screen or alert?

1 Answer

Hey Yacine, it didn't show the exact question you were asking about, was this it?

function getDay() {
  return "Monday";
  alert("Calculating day");
  return "Friday";
}

var dayOfWeek = getDay();

If so, you are correct, there is no output to the DOM or console coming from this function. This snippet of JavaScript is simply returning the value "Monday" when the getDay() function runs. This value is then set as the var dayOfWeek. This is still a functional piece of code without any console or HTML output, and often 100's of lines of code can be run behind the scenes of a webpage without specifically outputting the to DOM. It is part of what makes JavaScript so versatile.

Hope this helps!

Dylan