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 trialHumoyunmirzo Nosirov
Courses Plus Student 5,154 PointsI created A function , but I am stuck when it comes to call it
how is function called
function returnValue( hello ) {
var echo = returnValue('hello');
return barbeque;
}
<!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>
1 Answer
furkan
11,733 PointsYou were close! Note that you can only have one return statement inside a function. The question asks you to create a function that returns the value inside the function, and then create another variable that holds the value from the function.
So looking at the code you wrote above:
1) First, create a function using the function keyword and give it a name of returnValue. (which you have done so correctly. 2) Then inside the parentheses, provide a parameter, could be anything, which in this case you have put hello 3) In between the opening and closing braces, use the return keyword and return hello. 4) Outside of the function, under the function, create a new variable called echo with a value of the function name and opening and closing parentheses with anything inside the parentheses enclosed between quote marks (as a string)
And that should pass you through both of the questions for this challenge. I hope that has helped.
NOTE:
To call a function, you must use function name, like this: returnValue();