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

David Loder
David Loder
3,480 Points

How can I get this code to work? Having issues with it being "mocked"

There was an error with this code. It is basics to using functions. Does anyone have an idea?

script.js
function getYear() { 
  var year = new Date().getFullYear();
  return year();
}
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

Elijah Quesada
Elijah Quesada
Front End Web Development Techdegree Graduate 31,100 Points

Remove the parenthesis on line 3.

function getYear() { 
  var year = new Date().getFullYear();
  return year;
}