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
Ségolène Riquier
7,714 Points"Create a function named returnValue that accepts a single argument then returns that argument. "
The challenge is : "Create a function named returnValue that accepts a single argument (you can name it anything), then immediately returns that argument.
I tried : var x=0; function returnValue (x) { x += 1; return (x); };
But it seems wrong... what do they expect from me ??
2 Answers
Ben Reynolds
35,170 Pointsx += 1 is probably throwing it off. You don't need to do anything to x inside the function, only return it. I would remove that line, and you also don't need parentheses around x in the return statement.
Steven Parker
243,658 PointsThe challenge wants you to return the argument without making any changes to it. You also don't want to make any assumptions about what type the argument will be.
This code both assumes the argument is a number, and then changes the value of it by adding 1.