Learn AngularJS 1.X 9/11


#1

https://www.codecademy.com/courses/learn-angularjs/lessons/your-first-app/exercises/your-first-app-ng-click-i?action=lesson_resume

Error:

Oops! The test returned an error. Maybe you have a syntax error, or a typo. Hide error.
SyntaxError: Unexpected token ‘(’
, at /home/ccuser/workspace/angularjs-your-first-app/js/controllers/MainController.js:34

Unexpected ( but I copied the code exactly how it says,

  function(index) {  //This is line 34
  $scope.products[index].likes += 1; 
};

If you could figure out what I did wrong, that’d be great! Here’s my whole controller:

app.controller('MainController', ['$scope', function($scope) { 
  $scope.title = 'This Month\'s Bestsellers'; 
  $scope.promo = 'The most popular books this month.';
  $scope.products = [
  	{ 
    	name: 'The Book of Trees', 
    	price: 19, 
    	pubdate: new Date('2014', '03', '08'), 
    	cover: 'img/the-book-of-trees.jpg',
      likes: 0
  	}, 
  	{ 
    	name: 'Program or be Programmed', 
    	price: 8, 
    	pubdate: new Date('2013', '08', '01'), 
    	cover: 'img/program-or-be-programmed.jpg',
      likes: 0
  	}, 
  	{ 
    	name: 'Harry Potter & The Prisoner of Azkaban', 
    	price: 11.99, 
    	pubdate: new Date('1999', '07', '08'), 
    	cover: 'http://upload.wikimedia.org/wikipedia/en/b/b4/Harry_Potter_and_the_Prisoner_of_Azkaban_(US_cover).jpg',
      likes: 0
  	}, 
  	{ 
    	name: 'Ready Player One', 
    	price: 7.99, 
    	pubdate: new Date('2011', '08', '16'), 
    	cover: 'http://upload.wikimedia.org/wikipedia/en/a/a4/Ready_Player_One_cover.jpg',
      likes: 0
  	}
  ]
  function(index) { 
  $scope.products[index].likes += 1; 
};
}]);

#2

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.