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 trialdurul
62,690 PointsWhat is the Problem in my code ?
function returnValue(max) {
var echo = 'My argument';
return echo ;
}
6 Answers
Stephen Bone
12,359 PointsYou've already created your function so then all you need to do it call it. As below:
// here is your function used to pass the first challenge
function returnValue(max) {
var echo = max;
return echo;
}
// then you call it and assign it to the variable
var echo = returnValue('abc');
Stephen Bone
12,359 PointsJust try it again I updated the code a few seconds ago and wonder if you happened to try it while I changed it.
I left the closing brace in the wrong place.
Nir Tzezana
133 PointsSeems to work on my end: http://jsfiddle.net/21k285f1/
Stephen Bone
12,359 PointsHi Durul
You have to return the argument that is passed into the function, in your case max not set the variable echo to the string 'My argument'.
Your code should be as below
function returnValue(max) {
var echo = max;
return echo;
}
Hope it helps!
Gloria Dwomoh
13,116 PointsYou have to call the function outside of the braces, passing 'My argument' to it. Basically it asks you to this.
function returnValue(n){
return n; // you should use a more descriptive argument in general though
}
var echo = returnValue('My argument');
durul
62,690 Pointsthank you very much. I got it.... :)
Gloria Dwomoh
13,116 PointsYou are welcome.
durul
62,690 Pointsthe question is Now 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.
but my code is not still working
I could not take green light.
Stephen Bone
12,359 PointsSo the method for calling a function is to type the function name followed by the argument you want to pass into it in parenthesis.
And then to complete the challenge you need to pass this back into a variable named echo such as below:
var echo = returnValue('abc')
durul
62,690 Pointsit is not work.
function returnValue(max) { var echo = returnValue('abc') return echo; }
Dave McFarland
Treehouse TeacherDave McFarland
Treehouse TeacherHi,
To put code into a forum post use triple back ticks -- ``` — around the code. I fixed your code here, but in the future here's a forum discussion that describes how to add HTML, CSS, JavaScript or other code to the forum: https://teamtreehouse.com/forum/posting-code-to-the-forum