JavaScript JavaScript Basics Creating Reusable Code with Functions Returning a Value from a Function

Ronald Greer
Ronald Greer
43,528 Points

not sure what to do next on javascript basic Returning value

I've rewatched videos and can't seem to find the answer

function getYear () {
var year = new Date().getFullYear();
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>JavaScript Basics</title>
<script src="script.js"></script>

2 Answers

Hey Ronald,

I'm assuming you're on step 2 of this challenge. You're quite close! In step two, after adding the provided line of code inside the getYear function, it wants you to return the year variable on the next line. If you are unsure of how to do this, maybe give the "Getting Information From a Function" video one more watch.

Side note: watch your spacing and indentation. There should be no space between your function name and the following parentheses. Also, the first line inside your function should be indented by two spaces.

Let me know if you have any more questions!

Ronald Greer
Ronald Greer
43,528 Points

Thank you so much Matt, you and Cheo really helped!

You're close, you just need to do two things:

// return value

function() {
  var variable = functionCall();
   return variable;

and the second part is to save it's output in another variable.

var functionCallResult = functionCall();
Ronald Greer
Ronald Greer
43,528 Points

Thank you Cheo, you and Matt really helped