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

Returning a Value from a Function

Help! There was an error with your code: SyntaxError: Parse error. I don't understand what I'm doing wrong.

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

Piotr Manczak
Piotr Manczak
Front End Web Development Techdegree Student 14,779 Points

function getYear() {

var year = new Date().getFullYear();

return year;

}

var yearToday = getYear();

you can upvote me, please.