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

hunter bougis
hunter bougis
Full Stack JavaScript Techdegree Student 12,312 Points

why is it incorrect still?

keeps telling me i'm storing the return wrong....

function returnValue(sport) { var echo = 'soccer'; return sport; } returnValue('soccer');

script.js
function returnValue(sport) {
  var echo = 'soccer';
  return sport;
}
returnValue('soccer');
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

Matt Hanson
MOD
Matt Hanson
Treehouse Moderator 17,825 Points

Hey, Hunter. You're pretty close. Your echo variable needs to be outside of the returnValue function, and it should store your returnValue('soccer') call. This way the echo variable holds the result of calling returnValue.

diogorferreira
diogorferreira
19,362 Points

That's because you need to set the echo variable outside the function so it can be set to whatever the function returns.

function returnValue(sport) {
  return sport;
}
var echo = returnValue('soccer');