Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialAbdullahi Abdinasir Ali
9,520 PointsWhere am I getting wrong
How do I return the condition
function getYear(){
var DateOfYear = new ;
return "return year";
}
<!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>
Nick Gentile
4,237 PointsJust noticed you also copied the var that the task gives you wrong. You have it as
var DateOfYear = new ;
Whereas this is what they gave you to copy.
var year = new Date().getFullYear();
1 Answer
Katie Wood
19,141 PointsHi there,
First, you need to copy-paste the code the challenge gives you - it looks like this:
var year = new Date().getFullYear();
After that, you just need to return the year variable you just created:
return year;
Final code for this step will look like:
function getYear() {
var year = new Date().getFullYear();
return year;
}
Nick Gentile
4,237 PointsNick Gentile
4,237 PointsYou're returning the wrong thing.
The reason you created that variable:
var year = new Date().getFullYear();
is so that you could quickly return it. I'm unsure what you are going for in that last, but all you have to do is put:
return year;
And then you will be all set.
Once you create a variable, you no longer need to use quotes to call it, so thats why I am not doing return 'year';