Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript AngularJS Services and Dependencies Services: Factory

You never taught the viewers how to declare an object, this prevents us from actually completing the question.

First time trying to create an object.

app.js
angular.module('treehouseCourse', [])
.factory('Course', function() {
  var object = [
    {
      "title" : "Intro to Angular"
    }
   ];

  return object;

});
index.html
<!DOCTYPE html>
<html ng-app="treehouseCourse">
  <head>
    <title>Angular.js</title>
    <script src="js/angular.js"></script>
    <script src="app.js"></script>
  </head>
  <body ng-controller="MyCourseCtrl">
  </body>
</html>

3 Answers

Benedict, the course you're referring to is classified as an "Advanced" course, with other courses listed for content you should learn first. This is not the sort of course that will walk you through how to declare an object. If you don't already know how to do that, and many other Javascript basics, take a few less advanced JavaScript courses first and build up to this one.

I agree with Daniel. Declaring an object is covered in earlier courses. I would advise starting at the beginning and working your way up. There should be a track specifically designed for learning JS from the ground up.

On another note, unless you are declaring an array, you probably shouldn't be using square brackets in your JS code.

Good luck.

Andy Simmons
PLUS
Andy Simmons
Courses Plus Student 3,734 Points

As mentioned already, I wouldn't expect this course to teach how to create an object. Also, your var object is actually an array that's holding a set of objects.