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

Ingrid Bardales
Ingrid Bardales
10,616 Points

storing results of a function in a variable

Hi guys, I'm working of the this javascript challenge and to be perfectly honest i dont quite understand the last part, which is to store results of a function in a variable. Could someone please help me?

Ingrid Bardales
Ingrid Bardales
10,616 Points

'''javascript w that you've created the returnValue function, call it, by passing it a literal string value -- a series of characters in quote marks like this: 'My argument'. Store the results of the function in a variable named echo.

Bummer! Hmmm. It doesn't look like you're storing the returned value in the echo variable.

script.js
index.html

function returnValue( upper ){

return upper;

}

returnValue('My argument'); var echo = returnValue;

3 Answers

Hi! What it means is that you will be storing your answer from the function in a variable called echo.

The variable will be like "var echo", and it will be assigned the code for running the function like so:

    function returnValue(argument){
    return argument;
    }

    var echo = returnValue("My argument");

The value in the variable echo will be "My argument" since that is what was passed in the function and returned back.

Ingrid Bardales
Ingrid Bardales
10,616 Points

thank you Joakim, it was so easy..i cant believe i didn't get it! Argggh

Richmond Lauman
Richmond Lauman
28,793 Points

Hi Ingrid. Try like this: var echo = returnValue("My argument");