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 trialsuzan lohm
1,892 Pointscan't pass this 2nd part
asked for help already, but only recieved answers for first part of challenge that I passed already. Please help me pass this part
function returnValue(max) {
var echo="My argument";
return echo;
}
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JavaScript Basics</title>
</head>
<body>
<script src="script.js"></script>
</body>
</html>
2 Answers
Erik McClintock
45,783 PointsSuzan,
This challenge is a little tricky, since the function itself is not very helpful, and the phrasing is slightly confusing.
Basically, from task one of the challenge, you'll end up with a function that accepts one argument and then returns that argument (completely useless function, as they mention):
function returnValue(max) {
return max;
}
Then, for task two, they want you to call your function, passing in a string that says "my argument", and store the results of your function into a variable called "echo". This almost sounds like they're asking us to alter how the function works, but instead, it simply wants us to basically store the call to our function into that "echo" variable, since our function returns a value (that will now be stored in the "echo" variable). That probably still sounds confusing, but perhaps it will make more sense when you see it:
function returnValue(max) {
return max;
}
var echo = returnValue("my argument");
Again, this is a useless function, but what this does is store the value "my argument" into the variable "echo" after the string "my argument" passes through and is returned by the returnValue function.
Erik
Martin Wildfeuer
Courses Plus Student 11,071 PointsNow that you've created the returnValue function, call it, by passing it ... 'My argument'. Store the results of the function in a variable named echo.
You don't need to change the function from the first part. The assignment asks you to call the function you have created previously and assign it to a variable named echo.
suzan lohm
1,892 Pointssuzan lohm
1,892 PointsErik, Thank you for your help. I gave you best answer, you explained everything very clearly. Unfortunately, I typed it exactly what you've shown, and it still won't pass.
Erik McClintock
45,783 PointsErik McClintock
45,783 PointsSuzan,
When I copy and paste exactly what I have above into the challenge, it works just fine. If you copied and pasted my code, you need to make sure you've only got the function for Task 1, and then the full code present for Task 2. If you hand-typed it, please check your spelling and syntax. The code I included is 100% correct for this challenge, and verified as passing.
If you're still having trouble, please paste your code here and we'll take a look.
Erik