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 trialmo sam
1,002 PointsAfter your newly created returnValue function, create a new variable named echo. Set the value of echo to be the results
please answer this question
function returnValue(name){
var echo = return name;
}
returnValue("Mohammad");
<!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
Jennifer Nordell
Treehouse TeacherHi there, mo sam ! My guess (based on your code) is that for step 1 you had this:
function returnValue(name){
return name;
}
The second step of the challenge starts with this:
After your newly created returnValue function, create a new variable named echo.
But your echo
variable isn't after the function, it's inside it. We want to run this function and assign the value of whatever it returns to the variable echo
. So to alter your code to pass (it wouldn't be by much) you could do this:
function returnValue(name){
// name will now be equal to "Mohammed" when called
return name;
}
// create variable and call the function sending in "Mohammed"
// The echo variable is assigned the result "Mohammed" which is returned from the function
var echo = returnValue("Mohammad");
Hope this helps!
Adam Beer
11,314 PointsYou are near. There is a two ways. First, save the name in a variable, and finally return the value of variable, like this.
function returnValue(name){
var echo = name;
return echo;
}
returnValue("Mohammad");
or Second, return the value right away, like this,
function returnValue(name){
return name;
}
returnValue("Mohammad");
mo sam
1,002 PointsThanks alot
Steven Parker
231,236 PointsBut you'd still need to assign "echo" using the result of the function call.