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

Christopher Leveston
Christopher Leveston
2,987 Points

Not quite sure the question they're asking. Stuck on adding the string.

I'm not sure if I am getting what the question is asking for. I was able to display the value that I want in the function's parameters by calling it, but I am kinda confused on adding the string part. Here is what I got.

script.js
function returnValue(number,string) {
  return number;
  return string;
}
var echo = returnValue(10, "the string");
document.write(echo);
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

KRIS NIKOLAISEN
PRO
KRIS NIKOLAISEN
Pro Student 50,936 Points

I'm surprised the first task passes. According to the instructions you are to have a single parameter. Remove all code related to number and the document.write statement and you should pass.

Christopher Leveston
Christopher Leveston
2,987 Points

Oh wow! Thanks a bunch. During the first task, I assigned just one parameter to the function, but when I got to the next task, that's when I added all that extra nonsense LOL. While I was waiting on a response, it clicked that adding a second return wouldn't work because the program will only see the first return and not the 'return string', so I knew that was wrong. Thanks for the response!