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 Functions Pass Information Into Functions Pass an Argument to a Function

Natasha Harrington
Natasha Harrington
12,769 Points

Modify the returnValue function to accept one argument named value ?

Error stating that the function declaration doesn't have a parameter named value. What am I missing here?

script.js
const returnValue = (value) => {
  return value;
}
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>
Natasha Harrington
Natasha Harrington
12,769 Points

Also just as additional information I'm alternatively getting an error that says cannot read property '1' of null. On the same exact code. I even checked wrote the code in Atom checked that it worked (it does) and copied it back just to make sure i didn't have a syntax error in my original code. Not sure if I'm misunderstanding what they're asking for or?

2 Answers

Steven Parker
Steven Parker
231,269 Points

Even though it took it for task 1, I suspect this course doesn't cover or properly recognize the ES2015 "arrow" syntax.

For this course, try sticking with the conventional function definition syntax.

Natasha Harrington
Natasha Harrington
12,769 Points

You're right. It accepted it in the first step of the challenge so I didn't even question it, thanks I was losing my mind.

Brandon White
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Brandon White
Full Stack JavaScript Techdegree Graduate 35,771 Points

You’re not missing anything really.

Technically a function declaration takes this format:

function nameOfFunction (param) {};

What you’ve written is a function expression.

Your code works perfectly as is, but to complete this challenge you’ll need to declare your function using the function keyword.