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

Rakeeb Jalaldeen
Rakeeb Jalaldeen
3,847 Points

Whats wrong

Did I miss any code?

script.js
function getYear() {
var year = new Date().getFullYear();

}

return .getFullYear;
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

Paul Scanlon
PRO
Paul Scanlon
Pro Student 26,724 Points

Hey Rakeeb

The return keyword needs to be inside the function and return the variable "year" not its contents.

Hope that helped

Paul