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

My code is functioning perfectly when tested in the browser, so no idea why my answer is returned as incorrect...

I can't figure out why this keeps being deemed an incorrect answer to Challenge Task 1 - it's works perfectly fine when checked, and seems to fulfill the challenge prompt. What am I missing?

(Ps the alert was only to check that the function was working, code check fails with or without the alert)

script.js
function returnValue(qty) {
  var total = qty * 10;
  alert(total);
  return total;
}

returnValue(2);
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

Gareth Borcherds
Gareth Borcherds
9,372 Points

Sometimes the tests are a bit literal. It says to return the value and don't do anything to it. So to pass challenge 1 just use this.

function returnValue(qty) {
  return qty;
}

thanks....but UGH to that. I was convinced I was wrong. I think i've spend almost as much time figuring out how to get as close to literally answering the questions as possible so they pass, as I have actually answering the questions so that they work...

Thanks Dave McFarland

I know it was supposed to simplify the question, apparently I can't make things not make sense... :)

Dave McFarland
Dave McFarland
Treehouse Teacher

Ha! That's a good habit to have.