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 trialIngrid Bardales
10,616 Pointsstoring 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?
3 Answers
jne
12,613 PointsHi! 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
10,616 Pointsthank you Joakim, it was so easy..i cant believe i didn't get it! Argggh
Richmond Lauman
28,793 PointsHi Ingrid. Try like this: var echo = returnValue("My argument");
Ingrid Bardales
10,616 PointsThanks Richmond!
Faddah Wolf
12,811 Points^^^^^^ what Joakim Nereng Ellestad & Richmond Lauman said.
Ingrid Bardales
10,616 Pointsthanks Faddah!
Ingrid Bardales
10,616 PointsIngrid 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.function returnValue( upper ){
return upper;
}
returnValue('My argument'); var echo = returnValue;