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 trialMartin Bornman
Courses Plus Student 12,662 Pointsfunction
I am totally stuck with this problem.Can someone help please??
function returnValue( name ) {
echo =
return name;
}
<!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>
3 Answers
Steven Parker
231,269 PointsI'm guessing you passed Task 1 and started on Task 2, right? Here's a few hints:
- the challenge said "After your function...", but you started to put it inside your function
- remember to use the word var when declaring a new variable
- assign your new variable with the result of calling your function (the function name with ()'s after it)
- remember to give your function a string parameter (between the ()'s)
Arturo Alviar
15,739 PointsHi Martin,
Your function is correct but the echo declaration is in the wrong place.
Here is how should look like:
function returnValue(something){
return something
}
//Set the value of echo to be the results from calling the returnValue function.
var echo = returnValue("Hello!");
Hope this helps!
Martin Bornman
Courses Plus Student 12,662 PointsThanks Arturo !!!!
Shawn Denham
Python Development Techdegree Student 17,801 PointsOK this one is a bit of brain twister! Let's break it down. Step 1
_Create a function named returnValue that accepts a single argument (you can name it anything), then immediately returns that argument. _
so we have
function returnValue(myValue) {
return myValue;
}
//creates a function that accepts a value then returns that value.
next we have to _After your newly created returnValue function, create a new variable named echo. Set the value of echo to be the results from calling the returnValue function. When you call the returnValue function, make sure to pass in any string you'd like for the parameter. _
function returnValue(myValue) {
return myValue;
}
//call the function then pass a string
returnValue("Bob");
//this call the function and passes in "Bob" -> note the "" to make it a string.
Hope this helps
Martin Bornman
Courses Plus Student 12,662 PointsMartin Bornman
Courses Plus Student 12,662 PointsThanks Steven!!!