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

Karan Paul Chaudhary
seal-mask
.a{fill-rule:evenodd;}techdegree
Karan Paul Chaudhary
Full Stack JavaScript Techdegree Student 1,369 Points

not executing

function returnValue(drink){ var echo = 20+drink; return echo+"please"; } console.log(returnValue("coffee"));

script.js
function returnValue(drink){
  var echo = 20+drink;
  return echo+"please";
}
console.log(returnValue("coffee"));                         
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

Ari Misha
Ari Misha
19,323 Points

Hiya there! You're not doing what challenge asked you to do. Always stick to the instructions given in the challenge. Now regarding the challenge, task one wants you to create function named returnValue which takes a single argument. ANd you simply have to return this argument that was passed in to the function.

In task 2, you've to assign the result of reurnValue() to a variable named echo. This is how implemented my code:

function returnValue (drink) {
  return drink;
}

var echo = returnValue("coffee"); 
Steven Parker
Steven Parker
231,072 Points

Don't change the function you make in task 1. The code done for task 2 will go after the function and will use the function to get the value to assign to the new variable echo.