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

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

What am I doing wrong?

it keeps saying it can't find the variable 'soccer'...help please

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

script.js

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>

1 Answer

Two things; 1) inside method, you are returning wrong and undefined variable 2) you are calling method with undefined variable, instead of string

function returnValue(sport) { 
  return sport;
} 
returnValue("soccer");