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

JavaScript JavaScript Basics (Retired) Creating Reusable Code with Functions Passing an Argument to a Function

Samuel Igborgbor
Samuel Igborgbor
4,335 Points

Passing an argument to a function

After the code below i keep getting the response 'It looks like task 1 is no longer passing'

function returnValue(greeting) { var echo = greeting return greeting } returnValue(Hello)

script.js
function returnValue(greeting) {
 var echo = greeting
return greeting
}
returnValue(Hell0)
index.html
<!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

Florian Stegemann
seal-mask
.a{fill-rule:evenodd;}techdegree
Florian Stegemann
Full Stack JavaScript Techdegree Student 22,660 Points

According to the exercise the echo variable should be created outside of the function and it should be assigned the return value of a call of the returnValue function with a String argument:

function returnValue(arg) {
  return arg;
}

var echo = returnValue("Hallo");
Paul Walker
Paul Walker
28,904 Points

Hey Samuel,

Now this function will not display to anything, but that's how I would write it out. Hope that helps.

function returnValue ( greeting ) { return greeting; } returnValue("Hello");