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 Passing an Argument to a Function

Thomas Cormier
Thomas Cormier
2,496 Points

QUIZ HELP

I am stuck on the second part of this quiz. I have no idea what I am doing wrong and the quiz hints do not help at all. It also keeps "timing out" every time I submit my answer. I have to copy past my code:

function returnValue (breakfast) { var echo = (breakfast); return breakfast; } returnValue ('eggs');

Tushar Singh
Tushar Singh
Courses Plus Student 8,692 Points

First You have to create a function that returns the value that you pass in the function(argument) and then store it in a variable called "echo".

function returnValue(arg) {
  return arg
}
var echo = returnValue("Hello");

2 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Echo is a variable to be declared outside the function. The value of echo will be the string you pass to the function.

Take a look at my example:

function returnValue(myValue) {
  return myValue;
}

var echo = returnValue("This works!  YAY!");

We initialize a variable echo outside of the function by calling the function and then sending it a string. That string is now assigned to the variable echo.

When your challenge times out, click on the X to close the window. Don't click either of the two buttons offered. Then run check work again.