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 trial

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

Piotr Skutnik
seal-mask
.a{fill-rule:evenodd;}techdegree
Piotr Skutnik
Front End Web Development Techdegree Student 11,712 Points

Call the getYear function: store the returned value of the function in a new variable named yearToday.

This code Is Not Passing, I'm not sure what am I missing, pls help me with this my friends!

script.js
function getYear() {
   var year = new Data().getFullYear();
   return = year;
}

var yearToday = getYear(); 
if (getYear = = = true) { 
  alert(true);
}
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

Steven Parker
Steven Parker
231,269 Points

I see a few issues:

  • in the code the challenge gave you to paste in, somehow the word "Date" got changed to "Data".
  • there should not be an equal sign following the keyword return
  • the last 3 lines of JavaScript don't seem to be related to the challenge (and should be removed)